B4A Library [Tool] Simple Library Compiler - Build libraries without Eclipse

Status
Not open for further replies.
The purpose of Simple Library Compiler (SLC) is to make it easier to build libraries. SLC is responsible for taking the Java source code files and generating the Jar and XML files.

As I see it, it can be useful in two cases:
- Creating wrappers for 3rd party SDKs.
- Modifying and extending existing open source libraries.

Do note that you still need to provide the source code. This tool only helps with the building steps.

SS-2013-06-04_19.25.38.png


How to use

Using SLC is quite simple. The main project folder should include a folder named src and optionally a folder named libs.
The Java source code files should be under the 'src' folder. Java files are saved based on the package name. So if the package is com.example then the structure will be:

SS-2013-06-04_19.29.16.png


Under 'libs' folder you can put any additional libraries that should be referenced during compilation.
The 'bin' folder will be created during the build.

When you press on the Compile button the code will be compiled and the Jar file and XML files will be outputted to the "additional libraries folder" that is set in Basic4android configuration.

Wrapper example

The attached zip file includes a very simpler wrapper that wraps Flurry Analytics library.

The source code:

SS-2013-06-04_19.37.03.png


In order to compile it (and use it) you should download their SDK and copy FlurryAgent.jar to the project 'libs' folder and to the 'additional libraries folder'.

Tips

- A simple example is included in the package (FirstLib). It is recommended to start with it.
- You can use a text editor such as Notepad++ to write the Java code.
- Tutorials about libraries development are available in this forum: http://www.b4x.com/android/forum/forums/libraries-developers-questions.32/
- There is no installer. You should just unzip the package and run the program.
- If you need to include any additional files, such as .so files, in the jar then you can create a folder named 'additional'. Any file or folder inside this folder will be added to the jar file.
- Command line mode - You can also run this tool from the command line. It expects two arguments: library name and project path.

- B4J_SimpleLibraryCompiler is included in the zip file. It creates B4J libraries.
- In order to write the library code with Eclipse you need to reference Java 7 and also reference jfxrt.jar:

SS-2013-12-02_10.01.50.png


V1.12 (B4A) - source and target raised to Java 8.
V1.11 - SLC tools compiled with .Net Framework 4.
V1.10 - Adds support for the new structure of Additional libraries folder.
March 2018 - New zip with doclet v1.07.
V1.06 - Fixes the missing "bin\classes" issue.
V1.05 - Fixes an issue with old compiled class files not being deleted.
V1.03 - Fixes an issue related to B4A v5.
V1.02 - Allows usages of Java 7 features.
V1.01 - Fixes an issue with ignore field.

Download link: www.b4x.com/android/files/SimpleLibraryCompiler.zip

You should use Java 8 with SLC (at least when generating the XML).
 
Last edited:

tchart

Well-Known Member
Licensed User
Longtime User
V1.00 was released. Fixes the bug with the empty b4aignore field and also adds support for adding additional files to the jar. See the "Tips" in the first post.

Awesome work Erel. Its working great now and is including my .so files too!
 

tchart

Well-Known Member
Licensed User
Longtime User
You need to set the path to your "additional paths" folder in the B4A IDE

Look under Tools>Configure Paths
 

andre.astafieff

Member
Licensed User
Longtime User
You need to set the path to your "additional paths" folder in the B4A IDE

Look under Tools>Configure Paths

Ok :)

now displays the following error when compiling:

Starting step: Compiling Java code.
Completed successfully.
Starting step: Creating jar file.
Completed successfully.
Starting step: Creating XML file.
javadoc: error - No packages or classes specified.

Error.


se mando compilar novamente:

Starting step: Compiling Java code.
javac 1.7.0_21
javac: directory not found: bin\classes
Usage: javac <options> <source files>
use -help for a list of possible options


Error.
 

Marcob

Member
Licensed User
Longtime User
"Cannot find Basic4Android folder" error

When I run LibraryCompiler.exe I get this error.
I placed the file LibraryCompiler.exe into Basic4android folder.
I tried to add to the system path variable the string of the actual path:

E:\Programmi\adt-bundle-windows-x86-20130219\Anywhere Software\Basic4android\

but the error remains. Could the space between Anywhere and Software generate this problem ?
Do you have any suggestions ?

Thank you.

ps
I'm using WinXP
 

Attachments

  • CF_error.png
    CF_error.png
    8.3 KB · Views: 392

bloxa69

Active Member
Licensed User
Longtime User
Hi Erel, thanks for the SLC. I've done your FirstLib example successfully. I'm now struggling with the FlurryAgent lib. I've registered with flurray and downloaded the SDK. The only .jar file I got is Flurry_3.2.1.jar. I didn't get FlurryAgent.jar. When I compile a lib using the SLC, it is successful but the result is a 1kB .jar file in the Additional Liraries folder. This doesn't seem correct, or is it? I'm not sure because the FlurryAgent doc is very extensive. Here is a B4A code and contextual help snippet to show only 4 available items of a FlurryAgent lib.
1zvewyu.jpg


I then looked further on the Flurry website and saw this section...
Analytics/GettingStarted/Android - Flurry
Here it seems that the remainder of the lib components are included from the web at time of compiling. Is that correct or am I way off track here?

I guess the wrapper is supposed to be small, it's only several lines of code. The lib itself (Flurry_3.2.1.jar) is 1.7 MB and it's supposed to be in the same folder.
Anyway, I compiled it the same way, I get the same 3 properties/methods. I ran my test app and the session didn't register in my Flurry's account. I gave it one day to propagate, but still nothing.

Just in case the code:

B4X:
   fl.StartSession("MYFLURRYAPPKEY")
   fl.LogEvent("test1")
   fl.EndSession
 

stevel05

Expert
Licensed User
Longtime User
Thanks Erel,

Just tried this out, it's great tool. Nice and easy for one off libs.
 

Theera

Well-Known Member
Licensed User
Longtime User
How to download the FlurryAgent.jar?

Hi all,
In the website written as "Flurry Analytics isn't just free of charge." Do I must paid before to test? I would like the FlurryAgent.jar file directly. Could someone give me for test this thread?
 
Last edited:

Theera

Well-Known Member
Licensed User
Longtime User
Hi all,
I've tested another one instead of this, I've done it. Please forget my requested.
 
Status
Not open for further replies.
Top