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:

Douglas Farias

Expert
Licensed User
Longtime User
I am able to build the FirstLibrary test project which is included by default. But when i am adding these 2 imports to the same file i receive compillaion error as displayed in the image attached.
Can you please help me with this?
 

Attachments

  • error.jpg
    error.jpg
    271.4 KB · Views: 391
  • error.jpg
    error.jpg
    271.4 KB · Views: 380

Douglas Farias

Expert
Licensed User
Longtime User
Remove the import. It is not needed as it does not exists!
It does not just for this example. But the same error is displayed with some real examples. The same is with android.content.Context. Do you have any clue on this?
 

Serdar K.

Member
Licensed User
Longtime User
Hello,

I am trying to change the Parse 1.4 library for support different URL's, but i couldn't have success at first to compile the library as it is.

I wanted to test to compile the source code of 1.4, which Erel shared, with SLC.
The link is :
https://www.b4x.com/android/forum/attachments/parse_1-4_src-zip.41678/

But i have got an error and notes :

B4X:
Starting step: Compiling Java code.
javac 1.8.0_66
D:\SLC\Parse\src\anywheresoftware\b4a\objects\ParseObjectWrapper.java:602: error: <anonymous anywheresoftware.b4a.objects.ParseObjectWrapper$ParseQueryWrapper$2> is not abstract and does not override abstract method done(List,ParseException) in FindCallback
       {
       ^
Note: D:\SLC\Parse\src\anywheresoftware\b4a\objects\ParseObjectWrapper.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: D:\SLC\Parse\src\anywheresoftware\b4a\objects\ParseObjectWrapper.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
1 error


Error.

Do you have any ideas i could try?
 
Last edited:

Serdar K.

Member
Licensed User
Longtime User
May be it is a compatibility issue?
Hello,

I am trying to change the Parse 1.4 library for support different URL's, but i couldn't have success at first to compile the library as it is.

I wanted to test to compile the source code of 1.4, which Erel shared, with SLC. But i have got an error and notes :

B4X:
Starting step: Compiling Java code.
javac 1.8.0_66
D:\SLC\Parse\src\anywheresoftware\b4a\objects\ParseObjectWrapper.java:602: error: <anonymous anywheresoftware.b4a.objects.ParseObjectWrapper$ParseQueryWrapper$2> is not abstract and does not override abstract method done(List,ParseException) in FindCallback
       {
       ^
Note: D:\SLC\Parse\src\anywheresoftware\b4a\objects\ParseObjectWrapper.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: D:\SLC\Parse\src\anywheresoftware\b4a\objects\ParseObjectWrapper.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
1 error


Error.

Do you have any ideas i could try?
 
Last edited:

Roycefer

Well-Known Member
Licensed User
Longtime User
Is there any chance we could get an update to the B4A Simple Library Compiler to allow for usage of Java 8 language features?
 

peter01

Member
Licensed User
Longtime User
Hi Erel,

how can I set the native library path for the B4J SLC, so that the created jar Library can refer to my included jMath.dll file (in Windows). In B4J I get an java.lang.UnsatisfiedLinkError: no jMath in java.library.path error.

In Eclipse everything works with the include path for my jMath folder: C:\eclipse\workspace\jMath\additional for the native library location. I inspected the created jar file with 7-zip. the dll is in the root and the jMath class in the com/peter/jmath folder as specified in the java file.
 

somed3v3loper

Well-Known Member
Licensed User
Longtime User
Not a big issue but almost every time I press compile I get this log , the second try compile successfully .
B4X:
Starting step: Compiling Java code.
javac 1.7.0_79
javac: directory not found: bin\classes
Usage: javac <options> <source files>
use -help for a list of possible options


Error.

SLC 1.05
 

Johan Schoeman

Expert
Licensed User
Longtime User
Do you have a "libs" folder on the same folder level as the "src" folder that has the jar files that the library must be compile with? If not I will post it later today

Also, the -b4aignore field needs to be complete with the correct value (it could have been "com"). Check what the package names start with in the original Java project (not the wrapper)
 
Status
Not open for further replies.
Top