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.14 - Fixes an issue with running SLC from command line.
V1.13 - Added a field to set the path to Java 8 compiler (javac.exe). Should be similar to: C:\Program Files\Java\jdk1.8.0_211\bin\javac.exe
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:

B4JExplorer

Active Member
Licensed User
Longtime User
Not able to do this. Was able to generate the jar and xml, but when attempting to load it, there's an error about parsing libraries, that a routine already exists. I went ahead and removed the duplicate class files that contained that routine, and regenerated, but get the same error.

Sorry, but this is too complicated. Too many hoops to jump through, just to make an existing jar - that works everywhere else, as is - operate in the B4J world. I'll return to this, sometime in 2014.

I'm still very appreciative that this is being developed, and look forward to seeing how it evolves.
 

LucaMs

Expert
Licensed User
Longtime User
This will be my most hated post.

(I state that a long time ago I had seen the video tutorial on the construction of libraries and I also asked how to do, since it explained that you had to use "pure" Java code, non-Android. I did not get responses).

But if I knew well enough how to create libraries for B4A using Eclipse+Java ... why should I use B4A ?!?!?!

I use B4A just to keep myself away from the environment Eclipse / Java!

You could respond with sentences of your first post:

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


but still I should be familiar with Eclipse + Java to do this.

Ok, this tool will be useful to those who will create libraries for B4A that I will use :D

(Fortunately, there are not "Unlike" in this site :))
 
Last edited:

Sytek

Active Member
Licensed User
Longtime User

Attachments

  • parsingerror.jpg
    parsingerror.jpg
    241.4 KB · Views: 391

Sytek

Active Member
Licensed User
Longtime User
The XML file should not include the native methods and fields. Add com.chilkatsoft to the ignore field (assuming that you code is in a different package).

Hello Erel Thank's for reply me.
Sorry but I get the same error

B4X:
Starting step: Compiling Java code.
Completed successfully.
Starting step: Creating jar file.
Completed successfully.
Starting step: Creating XML file.
Loading source file C:\SimpleLibraryCompiler\chilkat-9.4.1-android-rsa\src\chilkat.java...
Loading source file C:\SimpleLibraryCompiler\chilkat-9.4.1-android-rsa\src\chilkatJNI.java...
Loading source file C:\SimpleLibraryCompiler\chilkat-9.4.1-android-rsa\src\CkByteData.java...
Loading source file C:\SimpleLibraryCompiler\chilkat-9.4.1-android-rsa\src\CkDateTime.java...
Loading source file C:\SimpleLibraryCompiler\chilkat-9.4.1-android-rsa\src\CkDtObj.java...
Loading source file C:\SimpleLibraryCompiler\chilkat-9.4.1-android-rsa\src\CkPrivateKey.java...
Loading source file C:\SimpleLibraryCompiler\chilkat-9.4.1-android-rsa\src\CkPublicKey.java...
Loading source file C:\SimpleLibraryCompiler\chilkat-9.4.1-android-rsa\src\CkRsa.java...
Loading source file C:\SimpleLibraryCompiler\chilkat-9.4.1-android-rsa\src\CkString.java...
Loading source file C:\SimpleLibraryCompiler\chilkat-9.4.1-android-rsa\src\SWIGTYPE_p_CkStringArray.java...
Loading source file C:\SimpleLibraryCompiler\chilkat-9.4.1-android-rsa\src\SWIGTYPE_p_int.java...
Loading source file C:\SimpleLibraryCompiler\chilkat-9.4.1-android-rsa\src\SWIGTYPE_p_JNIEnv.java...
Loading source file C:\SimpleLibraryCompiler\chilkat-9.4.1-android-rsa\src\SWIGTYPE_p_unsigned_char.java...
Loading source file C:\SimpleLibraryCompiler\chilkat-9.4.1-android-rsa\src\SWIGTYPE_p_void.java...
Loading source file C:\SimpleLibraryCompiler\chilkat-9.4.1-android-rsa\src\SWIGTYPE_p___int64.java...
Loading source file C:\SimpleLibraryCompiler\chilkat-9.4.1-android-rsa\src\SYSTEMTIME.java...
Constructing Javadoc information...
[-doclet, BADoclet]
[-docletpath, C:\SimpleLibraryCompiler]
[-bootclasspath, C:\android\sdk\platforms\android-11\android.jar]
[-classpath, C:\Program Files\Anywhere Software\Basic4android\Basic4android.exe\../libraries\B4AShared.jar;C:\Program Files\Anywhere Software\Basic4android\Basic4android.exe\../libraries\Core.jar;]
[-sourcepath, src]
[-b4atarget, C:\Program Files\Anywhere Software\Basic4android\Libraries\firmarsa.xml]
starting....
Working with class: com.chilkatsoft.chilkat
No ShortName annotation found for class: chilkat
Working with class: com.chilkatsoft.chilkatJNI
No ShortName annotation found for class: chilkatJNI
Working with class: com.chilkatsoft.CkByteData
No ShortName annotation found for class: CkByteData
Working with class: com.chilkatsoft.CkDateTime
No ShortName annotation found for class: CkDateTime
Working with class: com.chilkatsoft.CkDtObj
No ShortName annotation found for class: CkDtObj
Working with class: com.chilkatsoft.CkPrivateKey
No ShortName annotation found for class: CkPrivateKey
Working with class: com.chilkatsoft.CkPublicKey
No ShortName annotation found for class: CkPublicKey
Working with class: com.chilkatsoft.CkRsa
No ShortName annotation found for class: CkRsa
Working with class: com.chilkatsoft.CkString
No ShortName annotation found for class: CkString
Working with class: com.chilkatsoft.SWIGTYPE_p_CkStringArray
No ShortName annotation found for class: SWIGTYPE_p_CkStringArray
Working with class: com.chilkatsoft.SWIGTYPE_p_int
No ShortName annotation found for class: SWIGTYPE_p_int
Working with class: com.chilkatsoft.SWIGTYPE_p_JNIEnv
No ShortName annotation found for class: SWIGTYPE_p_JNIEnv
Working with class: com.chilkatsoft.SWIGTYPE_p_unsigned_char
No ShortName annotation found for class: SWIGTYPE_p_unsigned_char
Working with class: com.chilkatsoft.SWIGTYPE_p_void
No ShortName annotation found for class: SWIGTYPE_p_void
Working with class: com.chilkatsoft.SWIGTYPE_p___int64
No ShortName annotation found for class: SWIGTYPE_p___int64
Working with class: com.chilkatsoft.SYSTEMTIME
No ShortName annotation found for class: SYSTEMTIME
finish: C:\Program Files\Anywhere Software\Basic4android\Libraries\firmarsa.xml

Completed successfully.
*** Don't forget to refresh the libraries list in the IDE (right click and choose Refresh) ***
upload_2014-2-20_22-58-52.png

View attachment 22904
 

Sytek

Active Member
Licensed User
Longtime User
Sytek,

Do you have all of the annotations in the library? Your picture with "firma" has no version number next to it.
B4X:
@ShortName("firma")
@Author("sytek")
@Version(1.0f)

Hello Thank's for the reply
I'm sorry I took the source code from here http://www.chilkatsoft.com/download/chilkat-9.4.1-android-rsa.zip
I don't know where to put the version info.
But I edit the chilkat.java and put the following

package com.chilkatsoft;

import anywheresoftware.b4a.BA;
//import anywheresoftware.b4a.BA.ActivityObject;
import anywheresoftware.b4a.BA.ShortName;
import anywheresoftware.b4a.BA.Version;

@Version(1.0f)
@ShortName("chilkatsoft")
//@ActivityObject
//@Author("chilkatsoft")


............
..And the version does not appear thank's for considering myself
Best Regards
upload_2014-2-21_1-7-32.png
 

v150klaus

Member
Licensed User
Longtime User
Hello, does the simplelibrary Compiler works under win8 64bit?
The simplelibrary Compiler did not start !?
 

v150klaus

Member
Licensed User
Longtime User
starting " B4J_LibraryCompiler " Error = cannot find B4j ini file
starting "LibraryCompiler" Error = additional libraries folder must be set in the IDE "
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
starting " B4J_LibraryCompiler " Error = cannot find B4j ini file
Do you want to create a B4J library? Is B4J installed?

starting "LibraryCompiler" Error = additional libraries folder must be set in the IDE "
Open Tools - Configure Paths (in B4A IDE) and set the path of the additional libraries folder. The libraries will be created there.
 

v150klaus

Member
Licensed User
Longtime User
Thanks Erel.
Now it works !
I want to create a wrapper (library) for Sony SDK for the smartextensions.
Hope it works. I will start with the examples for simple libray Compiler.
 
Last edited:

Alberto Iglesias

Well-Known Member
Licensed User
Longtime User
Dear advanced users,

I have a library project in Eclipse, and compile very well, but not generate the .JAR FILE and in the SIMPLE LIBRARY COMPILE, i got a error.. look in attachment screenshot

if I remove the import com.google.android.glass.app.Card; and the functions related, works in SLC, where I need to put the GDK.jar to compile ok?

Or maybe, how to do to compile .JAR automaticly in ECLIPSE?

Thanks.....
 

Attachments

  • ErrorSLC.jpg
    ErrorSLC.jpg
    232.1 KB · Views: 340
Status
Not open for further replies.
Top