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:

Cassandro SCOLA

New Member
Licensed User
Longtime User
I have the following problem when you use the compiler package android.support.v7.app first error does not exist but I solved by inserting android-support-v7-appcompat.jar in my project / lib.
Now error R package does not exist, but in eclipse software works perfectly without error, how do I fix?
errore.png
 

Cassandro SCOLA

New Member
Licensed User
Longtime User
thanks for the help but as mentioned in the eclipse project works, perhaps lacks some reference to this r.java file folders as photos attached from which we see that there is no error in eclipse.
 

Attachments

  • r.jpg
    r.jpg
    83.6 KB · Views: 204

Cassandro SCOLA

New Member
Licensed User
Longtime User
thanks for the help but put r.java not give up work in B4A wait to finish the project directly in eclipse since so I have no problems. Thanks again'll use the compiler for other projects since it works well in other projects. Thanks again. greetings Cassander
 

Thuong

Member
Licensed User
Longtime User
Dear Erel
My company send to me SDK for android, but I don't see src folder
How to wrapper it to B4A library?
Can you help me
Thank
 

Attachments

  • ThinkGearBase.jar
    27.5 KB · Views: 203
  • ThinkGearPackX.jar
    75.6 KB · Views: 201

zolive33

Active Member
Licensed User
Longtime User
hi Erel,

There is a little problem with SLC and B4A v5.00. SLC cannot find the Basic4Android ini file.
The file "b4aV0.1.ini" is now called "b4xV5.ini".

Regards.
 

Attachments

  • Capture du 2015-06-08 23:14:26.png
    Capture du 2015-06-08 23:14:26.png
    9.8 KB · Views: 190

zolive33

Active Member
Licensed User
Longtime User
hi Erel,

Another problem with SLC v1.03 : "unmappable character for encoding UTF-8".

Screenshot 1 : no problem with SLC v1.01
Screenshot 2 : Error with SLC v1.03
 

Attachments

  • Capture du 2015-06-10 23:11:48.png
    Capture du 2015-06-10 23:11:48.png
    141.6 KB · Views: 194
  • Capture du 2015-06-10 23:13:15.png
    Capture du 2015-06-10 23:13:15.png
    31.7 KB · Views: 198

zolive33

Active Member
Licensed User
Longtime User
Thank you, Erel. It's OK.

2 solutions with Eclipse :
- 1 : Windows > Preferences > General > Content Types, set UTF-8 as the default encoding for Java source file.
or
- 2 : Project properties > Resource / Text file encoding Other : UTF-8 (I prefer this option)
 

agb2008

Member
Licensed User
Longtime User
I am trying to convert non UI Java library to B4J - I've manage to get it compiled correctly and to appear in extralibs folder together with xml file for it
but I can't use it in B4J - it's listed in the libs option but can't see lib version assosiated with it. There were a message in this thread that one have to add

@Version(1.0)
@ShortName("rand")

But when I added this information to java class files I've got error message:

error: cannot find symbol
@Version(1.0)
^
symbol: class Version
1 error

Could you please advice what might be wrong ?
 

agb2008

Member
Licensed User
Longtime User
Erel,

Issue resolved. Proplem was related to the fact that I tried to create library for B4J and forgot to include this code:

B4X:
import anywheresoftware.b4a.BA;
import anywheresoftware.b4a.BA.*;

After correction library compiled O.K. without errors related to "cannot find symbol"

But another issue noted - in my case java library source code cosist of many .java files. I've added following code
to every .java class source file such as:

B4X:
import anywheresoftware.b4a.BA;
import anywheresoftware.b4a.BA.*;

@Version(1.0f)
@ShortName("rand")
@Author("Author Name")

And got error message... :-( Solution was to remove "@Version(1.0f)" from almost all .java files and leave only
one with such statement. Resulting compilation was O.K., library version displayed correctly and it is usable with
B4J (my assumption is that it would compile O.K. for B4A as well)
 

walterf25

Expert
Licensed User
Longtime User
Finally I not succeed to access embedded files with ClassLoader.
Instead I put my needed files in /additional/assets/ of my wrapper class, then I add and use BA.applicationContext.getAssets() to get it.
If this can help someone with similar problems...:)
Hi kiki78, i'm wrapped the same library for ffmpeg but i'm having some issues as i understand the binary files have to be built, as i have no idea how to do this i'm really stuck and i really need to finish this library for a project i have been working on. Were you successful on making the wrapper for this? if so would you be able to share it, or walk me through the process of building the binary files?

Please let me know!

Thanks,
Walter
 
Status
Not open for further replies.
Top