B4A Library [Tool] B4A Library Generator

Basic4Android Library Generator

d4hpnjD.png

Hi folks,

I'm proud to unveil my latest project: B4A Library Generator.
This tool generates .java files from native jar files which are compatible with Basic4Android.
Note that this is NOT a miraculous program that automatically creates a b4a library from any normal java library.

Instead this tool imports and generates the classes you chose from a jar file and generates:
- Package
- Imports
- Annotiations (manifest)
- Permissions
- Attributes
- Initialize
- Getters
- Setters
- and all other methods from the jar file.

Let's take a look at the outcome:

My written version of SocialAuth Contact Class:
[Java] Basic4Android SocialAuth - Pastebin.com

It took me perhaps 15 minutes to type all above

Basic4Android Library Generator
[Java] Basic4Android SocialAuth Library Generator - Pastebin.com
The class was generated in less than 1 minute, and added everything needed.
No changes has been made!


Instructions:
The tool is very easy to use.
1. Select jar file
2. Enter ShortName, Package name, Author, Version and if it's an Activity Object.
* Note that during every compile time, the author and version becomes empty.
This is due every library can only have one author and version annotiation in the project. Just leave it empty for your next classes.
3. Click the Permissions button and add every permission you want.
e.g "android.permission.INTERNET" click ok, and click button again for the next one.
* Note that after compiling, the permissions gets removed and you'll have to enter them again for other classes.
4. From the left list, select the classes you want to generate and move them to the right list with the buttons.
5. At the right side, select the class you wish to compile.
6. Compile! A workspace will have been created in the same directory of the jar file.
7. For other classes, you'll have to change the ShortName, and select the new class.

(I was planning to add compiling too (to .class files and .jar), that's why the button is called Compe rather than generate.


Download:
The tool is available for free here:
https://www.dropbox.com/s/68dw143ou16tsk5/B4ALibGen.zip

I recommend scanning for virusses if you don't trust it, and happy lib making! ;)

Have fun!
Tomas
 

bloxa69

Active Member
Licensed User
Longtime User
null pointer error

XverhelstX,
thanks a lot for sharing. I've tried your tool and managed to create a wrapper code (I guess it's the main functionality of your tool for now?) I can export xml and .jar from Eclipse, can initialize my lib object and see some properties and methods, but then i hit the wall - no matter what property or method I use, I get null pointer error.
It would be really great if you posted a sample code (Eclipse project for a simple .jar library wrapper) and a little tutorial covering the tight corners so we know what to expect and how to avoid the pitfalls while wrapping a .jar library and exporting it to B4A.
There is a Tutorial Wish post here, many people voted for it, but sofar nobody volunteered for it:
http://www.b4x.com/forum/bugs-wishl...ndroid-java-class-b4a-library.html#post151416

Thanks!:sign0188:
 

XverhelstX

Well-Known Member
Licensed User
Longtime User
XverhelstX,
thanks a lot for sharing. I've tried your tool and managed to create a wrapper code (I guess it's the main functionality of your tool for now?) I can export xml and .jar from Eclipse, can initialize my lib object and see some properties and methods, but then i hit the wall - no matter what property or method I use, I get null pointer error.
It would be really great if you posted a sample code (Eclipse project for a simple .jar library wrapper) and a little tutorial covering the tight corners so we know what to expect and how to avoid the pitfalls while wrapping a .jar library and exporting it to B4A.
There is a Tutorial Wish post here, many people voted for it, but sofar nobody volunteered for it:
http://www.b4x.com/forum/bugs-wishl...ndroid-java-class-b4a-library.html#post151416

Thanks!:sign0188:

I'll see what I can do.
This tool only makes development easier and quicker by generating a java file with the methods of the class file from the jar file. It's not a magical tool that will make any b4a compatible library.

Tomas
 

bloxa69

Active Member
Licensed User
Longtime User
It's not a magical tool that will make any b4a compatible library.
Hey Tomas, I understand that. Thanks for reply.
There is no tutorial in that area - wrappers for .jar files and export and usage in B4A afterwards, so we could use any help. I wouldn't bother with Java at all if not for hardware accelerated live wallpaper library I badly need. I am sure I'm not alone.
 

silverbyte

Member
Licensed User
Longtime User
OMG this is OUTSTANDING! Although I am unsuccessful, when I select my JAR file nothing happens, doesn't show anything on the screen and of course the compile button is grayed out.
 

silverbyte

Member
Licensed User
Longtime User
Alright, realized I needed to extract the library(jar) within the jar file. Now it loads up although pressing compile doesn't produce any files.
 

silverbyte

Member
Licensed User
Longtime User
I should read the steps carefully before asking questions... My mistake was I was not selecting the Class and assigning a new short name

7. For other classes, you'll have to change the ShortName, and select the new class.

seems to be working now
 

Theera

Well-Known Member
Licensed User
Longtime User
I'll see what I can do.
This tool only makes development easier and quicker by generating a java file with the methods of the class file from the jar file. It's not a magical tool that will make any b4a compatible library.

Tomas

Hi Tomas,

Do your program help me change others' libraries in Thai edition easier,Yes or No? I'm not understand English very well. I've tried it already.

Best Regards
Theera
 
Last edited:

StarinschiAndrei

Active Member
Licensed User
Longtime User
Hi XverhelstX, i downloaded the zip , but inside there is no exe file. could you please send me the link to download the complete version ?
Thank you in advance
 

Alberto Iglesias

Well-Known Member
Licensed User
Longtime User
Tomas, do you know why not work 100% with this google .jar?

GDK.jar is a library to help creating app to Google Glasse, and is avaiable in ANDROID SDK in API 15 (Android 4.0.3) like:

- Glass Development Kit Sneak Peek

Can you taking a look?


Apears for me a lot of erros when try to compile, look:

Loading source files for package anywharesoftware.b4a.sample...
C:\workspace_mobile\FirstLib\src\anywharesoftware\b4a\sample\FirstLib.java:71: ')' expected
return this.card.addImage(Uri arg0);
^
C:\workspace_mobile\FirstLib\src\anywharesoftware\b4a\sample\FirstLib.java:71: illegal start of expression
return this.card.addImage(Uri arg0);
^
C:\workspace_mobile\FirstLib\src\anywharesoftware\b4a\sample\FirstLib.java:75: '.class' expected
return this.card.addImage(int arg0);
^
C:\workspace_mobile\FirstLib\src\anywharesoftware\b4a\sample\FirstLib.java:75: ';' expected
return this.card.addImage(int arg0);
^
C:\workspace_mobile\FirstLib\src\anywharesoftware\b4a\sample\FirstLib.java:87: illegal start of expression
this.card.clearImages( }
^
C:\workspace_mobile\FirstLib\src\anywharesoftware\b4a\sample\FirstLib.java:87: ';' expected
this.card.clearImages( }
^
C:\workspace_mobile\FirstLib\src\anywharesoftware\b4a\sample\FirstLib.java:89: illegal start of expression
public void setImageLayout(ImageLayout arg0){
^
C:\workspace_mobile\FirstLib\src\anywharesoftware\b4a\sample\FirstLib.java:89: ';' expected
public void setImageLayout(ImageLayout arg0){
^
C:\workspace_mobile\FirstLib\src\anywharesoftware\b4a\sample\FirstLib.java:89: ';' expected
public void setImageLayout(ImageLayout arg0){
^
C:\workspace_mobile\FirstLib\src\anywharesoftware\b4a\sample\FirstLib.java:93: illegal start of expression
public ImageLayout getImageLayout() {
^
C:\workspace_mobile\FirstLib\src\anywharesoftware\b4a\sample\FirstLib.java:93: ';' expected
public ImageLayout getImageLayout() {
^
C:\workspace_mobile\FirstLib\src\anywharesoftware\b4a\sample\FirstLib.java:97: illegal start of expression
public View toView(){
^
C:\workspace_mobile\FirstLib\src\anywharesoftware\b4a\sample\FirstLib.java:97: ';' expected
public View toView(){
^
C:\workspace_mobile\FirstLib\src\anywharesoftware\b4a\sample\FirstLib.java:102: reached end of file while parsing
}
^
14 errors
 

Attachments

  • gdk.jar
    14.5 KB · Views: 249
  • librarygenerator.jpg
    librarygenerator.jpg
    39.6 KB · Views: 224
Top