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

Discussion in 'Additional libraries, classes and official updates' started by Erel, Jun 4, 2013.

Thread Status:
Not open for further replies.
  1. Erel

    Erel Administrator Staff Member Licensed User

    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.


    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:


    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:


    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'.


    - 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.basic4ppc.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:


    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
    Last edited: Aug 16, 2019
  2. thedesolatesoul

    thedesolatesoul Expert Licensed User

    This will be incredibly useful even with eclipse.
    Probably write all the code in eclipse (intellisense) and solve all the warnings. Then use this tool to compile and copy everything. And I guess if you are feeling particularly lucky, write the code in Notepad++ (not me).
    Thanks :sign0098:
    Kwame Twum and Peter Simpson like this.
  3. ivanomonti

    ivanomonti Well-Known Member Licensed User

    Grazie - Thank 10000000000000000000 :)
  4. Erel

    Erel Administrator Staff Member Licensed User

    That is 100% correct.
  5. MLDev

    MLDev Active Member Licensed User

    Thanks Erel!
    I've configured it as an external tool in eclipse. It works great. :sign0098:
    Kwame Twum likes this.
  6. tchart

    tchart Active Member Licensed User

    This is awesome news! Thanks Erel.
  7. tchart

    tchart Active Member Licensed User

    Erel, any chance we can get a command line version of this tool? Or does the tool support command line arguments? I would love to be able to just run a batch file to compile my library each time.
    Last edited: Jun 4, 2013
  8. vampirbcn

    vampirbcn Active Member Licensed User

    Thanks Erel!
  9. Theera

    Theera Well-Known Member Licensed User

    Hi Erel,
    This feather will be a part of B4A ,Yes or No? If Yes,I'll be very happy :),Thank a lot.
    Last edited: Jun 5, 2013
  10. Erel

    Erel Administrator Staff Member Licensed User

    V0.95 is now available. Adds support for command line mode.

    The program expects two arguments: library name and project path.
    newSteve likes this.
  11. tchart

    tchart Active Member Licensed User

    Thank you Erel. I will try the new options out now :D
  12. tchart

    tchart Active Member Licensed User


    Thank you so much for this tool. It will make life so much easier.

    I have tried the GUI and command line and it does "compile" my wrapper library.

    But what is missing are my ".so" files.

    I though by including these under the \libs folder they would be picked up and added to the JAR file but they aren't. I also tried putting them under \lib with no luck.

    Any chance this feature can be included in the next version?

    The reason this is important to me is that (as I've mentioned before) I have a library wrapper which I cant actually distribute since it is against the license agreement. If B4A users can obtain the JAR & .so files themselves and then use your wonderful compiler then I could distribute it that way.

    Thanks in advance.

  13. Erel

    Erel Administrator Staff Member Licensed User

    It can be added in a future version. For now you can manually open the jar file (it is a zip file) and put the so files in the correct folder.

    7zip is a good tool for such actions.
  14. tchart

    tchart Active Member Licensed User

    Thanks Erel

    Ive added the following to my compile batch file using 7-zip;

    "D:\program files\7-zip\7z" a D:\Basic4android\AdditionalLibraries\myLib.jar E:\Share\myLib\lib

    This adds the .so files (Ive not tested on a device yet but it seems to be correctly located in the JAR.

    If you could add this as an option to a future version I would be very happy.

  15. FabioG

    FabioG Active Member Licensed User


    Thank you Erel!!!
  16. tchart

    tchart Active Member Licensed User


    Ive just noticed a problem with the SLC. It could be something I've done but let me explain.

    I'm using the command line like this;

    LibraryCompiler.exe Blah2 E:\Share\AGSforAndroidProxy

    The command is successful and the JAR gets created but one of my declarations in B4A is not recognized;

    Dim gl As GraphicsLayer

    Now looking at the output from the tool I see these lines;

    [-b4aignore, E:\Share\AGSforAndroidProxy\src\com\tchart\ags\proxy\android\map\GraphicsLayerWrapper.java]
    Ignoring: [E:\Share\AGSforAndroidProxy\src\com\tchart\ags\proxy\android\map\GraphicsLayerWrapper.java]

    I know if I run the SLC in GUI mode there is an ignore option but it is not set anywhere in my command line. The GUI (which appears to remember the settings) is also blank.

    The thing is that the declaration that fails is in the source being ignored which also happens to be the first source file the program encounters.

    UPDATE: I have found that if I actually put something in the GUI (eg com.moo) then the missing source is included. So seems like a bug if the value is set to blank/nothing. Is there an option to set this with the command line operation?

    Last edited: Jun 6, 2013
  17. Erel

    Erel Administrator Staff Member Licensed User

    I see it too. It will be fixed in the next update. For now you should make sure that the ignore field (in the GUI) is not empty. In most cases you do not need to change it. You can just write xxx in this field. Any package that starts with xxx will be ignored.
  18. tchart

    tchart Active Member Licensed User

    Thanks Erel. This tool has saved me so much time!
  19. Erel

    Erel Administrator Staff Member Licensed 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.
  20. Informatix

    Informatix Expert Licensed User

    I have no use for this but it's a great addition to B4A. Thanks.
Thread Status:
Not open for further replies.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice