On YouTube I've found a simple tutorial to build a B4A library and I've followed step-by-step all the instructions.
This is Java code:
As of instructions I've referenced these jars:
Core.jar
B4AShared.jar
android.jar
The JDK version is 1.8
I've created without problems FirstLib2.jar and FirstLib2.xml in AddLibraries directory.
Then I created test_FirstLib2:
Running test_FirstLib2 it gives me this error:
B4A version: 6.00
Parsing code. (0.00s)
Compiling code. (0.05s)
Compiling layouts code. (0.01s)
Organizing libraries. (0.01s)
Generating R file. (1.43s)
Compiling debugger engine code. (2.31s)
Compiling generated Java code. (2.72s)
Convert byte code - optimized dex. Error
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dx.cf.iface.ParseException: bad class file magic (cafebabe) or version (0034.0000)
at com.android.dx.cf.direct.DirectClassFile.parse0(DirectClassFile.java:472)
at com.android.dx.cf.direct.DirectClassFile.parse(DirectClassFile.java:406)
at com.android.dx.cf.direct.DirectClassFile.parseToInterfacesIfNecessary(DirectClassFile.java:388)
at com.android.dx.cf.direct.DirectClassFile.getMagic(DirectClassFile.java:251)
at com.android.dx.command.dexer.Main.processClass(Main.java:598)
at com.android.dx.command.dexer.Main.processFileBytes(Main.java:570)
at com.android.dx.command.dexer.Main.access$2(Main.java:546)
at com.android.dx.command.dexer.Main$2.processFileBytes(Main.java:514)
at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:284)
at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:166)
at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)
at com.android.dx.command.dexer.Main.processOne(Main.java:537)
at com.android.dx.command.dexer.Main.processAllFiles(Main.java:449)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:236)
at com.android.dx.command.dexer.Main.run(Main.java:206)
at com.android.dx.command.dexer.Main.main(Main.java:179)
at com.android.dx.command.Main.main(Main.java:103)
...while parsing anywheresoftware/b4a/sample/FirstLib2.class
1 error; aborting
Any suggestion?
thank you
Roberto
This is Java code:
B4X:
package anywheresoftware.b4a.sample;
import anywheresoftware.b4a.BA.ShortName;
@ShortName("FirstLib2")
public class FirstLib2 {
/**
* test wrapper semplice B4a
* @param x : numero da moltiplicare
* @return : x * 2
*/
public int multiply(int x) {
return x * 2;
}
}
As of instructions I've referenced these jars:
Core.jar
B4AShared.jar
android.jar
The JDK version is 1.8
I've created without problems FirstLib2.jar and FirstLib2.xml in AddLibraries directory.
Then I created test_FirstLib2:
B4X:
#Region Project Attributes
#ApplicationLabel: B4A Example
#VersionCode: 1
#VersionName:
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: unspecified
#CanInstallToExternalStorage: False
#End Region
#Region Activity Attributes
#FullScreen: False
#IncludeTitle: True
#End Region
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Dim fl As FirstLib2
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
'Activity.LoadLayout("Layout1")
Log(fl.multiply(10))
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Running test_FirstLib2 it gives me this error:
B4A version: 6.00
Parsing code. (0.00s)
Compiling code. (0.05s)
Compiling layouts code. (0.01s)
Organizing libraries. (0.01s)
Generating R file. (1.43s)
Compiling debugger engine code. (2.31s)
Compiling generated Java code. (2.72s)
Convert byte code - optimized dex. Error
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dx.cf.iface.ParseException: bad class file magic (cafebabe) or version (0034.0000)
at com.android.dx.cf.direct.DirectClassFile.parse0(DirectClassFile.java:472)
at com.android.dx.cf.direct.DirectClassFile.parse(DirectClassFile.java:406)
at com.android.dx.cf.direct.DirectClassFile.parseToInterfacesIfNecessary(DirectClassFile.java:388)
at com.android.dx.cf.direct.DirectClassFile.getMagic(DirectClassFile.java:251)
at com.android.dx.command.dexer.Main.processClass(Main.java:598)
at com.android.dx.command.dexer.Main.processFileBytes(Main.java:570)
at com.android.dx.command.dexer.Main.access$2(Main.java:546)
at com.android.dx.command.dexer.Main$2.processFileBytes(Main.java:514)
at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:284)
at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:166)
at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)
at com.android.dx.command.dexer.Main.processOne(Main.java:537)
at com.android.dx.command.dexer.Main.processAllFiles(Main.java:449)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:236)
at com.android.dx.command.dexer.Main.run(Main.java:206)
at com.android.dx.command.dexer.Main.main(Main.java:179)
at com.android.dx.command.Main.main(Main.java:103)
...while parsing anywheresoftware/b4a/sample/FirstLib2.class
1 error; aborting
Any suggestion?
thank you
Roberto