Java Question How to use this library.

freetoair

Member
Licensed User
Longtime User
I got by manufacturers library for serial interface. I guess you can not directly use it but must be adapted for B4A. I tried LibraryCompiler but I could not get .XML file ?
 

Attachments

  • libs.zip
    7.7 KB · Views: 255

Roycefer

Well-Known Member
Licensed User
Longtime User
Do you have any documentation for the library? You have a few options.
  1. You could write a Java wrapper for the library and use SimpleLibraryCompiler to generate the XML file. SLC will also generate a jar but if you want the .so file packaged in the jar, you'll have to use NetBeans or Eclipse to build the jar (or some zip tools like 7-zip, maybe).
  2. You could write a B4A class that uses a lot of JavaObject and #AdditionalJar. A tool like JD-GUI will help you figure out what methods to call if you don't have any documentation.
  3. Post a bounty for the library in the Job Offers forum and pay someone to do it. You'll need to know precisely what functionality you want exposed, though.
 

freetoair

Member
Licensed User
Longtime User
I have the whole project but a large even when the zip. In the cource file can to see which functions are calling.
 

Attachments

  • MainActivity.zip
    4.2 KB · Views: 263

Informatix

Expert
Licensed User
Longtime User
Do you have any documentation for the library? You have a few options.
  1. You could write a Java wrapper for the library and use SimpleLibraryCompiler to generate the XML file. SLC will also generate a jar but if you want the .so file packaged in the jar, you'll have to use NetBeans or Eclipse to build the jar (or some zip tools like 7-zip, maybe).
  2. You could write a B4A class that uses a lot of JavaObject and #AdditionalJar. A tool like JD-GUI will help you figure out what methods to call if you don't have any documentation.
  3. Post a bounty for the library in the Job Offers forum and pay someone to do it. You'll need to know precisely what functionality you want exposed, though.
The Simple Library Compiler can include .so files if you place them in an "additional" folder. It's explained in the thread of SLC.
 

freetoair

Member
Licensed User
Longtime User
I finally succeeded to compile a library from guidance the forum. I've got a .jar and .xml file, but not to work. Do you now have to use SLC to get a working version for b4a?
 

Attachments

  • serialDWIN.zip
    1.8 KB · Views: 226
  • serialDWINsource.zip
    1.1 KB · Views: 245

onair

Member
Licensed User
Longtime User
Does anyone know what this means:

B4A version: 5.20
Parsing code. (0.01s)
Compiling code. (0.05s)
Compiling layouts code. (0.00s)
Generating R file. (0.12s)
Compiling generated Java code. (2.34s)
Convert byte code - optimized dex. Error
UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.RuntimeException: Exception parsing classes
at com.android.dx.command.dexer.Main.processClass(Main.java:752)
at com.android.dx.command.dexer.Main.processFileBytes(Main.java:718)
at com.android.dx.command.dexer.Main.access$1200(Main.java:85)
at com.android.dx.command.dexer.Main$FileBytesConsumer.processFileBytes(Main.java:1645)
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:672)
at com.android.dx.command.dexer.Main.processAllFiles(Main.java:574)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:311)
at com.android.dx.command.dexer.Main.run(Main.java:277)
at com.android.dx.command.dexer.Main.main(Main.java:245)
at com.android.dx.command.Main.main(Main.java:106)
Caused by: 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.parseClass(Main.java:764)
at com.android.dx.command.dexer.Main.access$1500(Main.java:85)
at com.android.dx.command.dexer.Main$ClassParserTask.call(Main.java:1684)
at com.android.dx.command.dexer.Main.processClass(Main.java:749)
... 12 more
1 error; aborting



This message I get when I tried to compile a program with a library that I've made as instructed by the forum about creating libraries for B4A ?!?
 

DonManfred

Expert
Licensed User
Longtime User
Please upload you Library including xmlseems that is Contains much more then expected
 

onair

Member
Licensed User
Longtime User
First I want to mention that this library is not my work, I got it from hardware manufacturer. But to see if everything is well to translate libraries I followed Instruction from the forum B4A and websites http://www.rwblinn.de/142k2t9.htm, but unfortunately in both cases I got the same error. I have many times I checked whether I have made additional libraries in Eclipse and I could not find fault.
 

onair

Member
Licensed User
Longtime User
Hi, Erel

Yes, is compiled with Java 8. I never knew that could be a problem. Does this mean that I have in configure paths to change the Java 7 or does it apply only to compile a library?
 

onair

Member
Licensed User
Longtime User
Interestingly, when I did the same library compiled with SLC then everything was OK.
 

onair

Member
Licensed User
Longtime User
After a few months I finally managed to get a library that compiles correctly with B4A. But now I have another problem I keep getting this message from the android on which the program is installed:

** Activity (main) Create, isFirst = true **
main_activity_create (java line: 336)
java.lang.UnsatisfiedLinkError: Native method not found: serialDWIN.serialDWIN.openDev:(I)Ljava/io/FileDescriptor;
at serialDWIN.serialDWIN.openDev(Native Method)
at b4a.example.main._activity_create(main.java:336)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:169)
at b4a.example.main.afterFirstLayout(main.java:102)
at b4a.example.main.access$000(main.java:17)
at b4a.example.main$WaitForLayout.run(main.java:80)
at android.os.Handler.handleCallback(Handler.java:615)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4745)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
main_activity_create (java line: 336)
java.lang.UnsatisfiedLinkError: Native method not found: serialDWIN.serialDWIN.openDev:(I)Ljava/io/FileDescriptor;
at serialDWIN.serialDWIN.openDev(Native Method)
at b4a.example.main._activity_create(main.java:336)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:169)
at b4a.example.main.afterFirstLayout(main.java:102)
at b4a.example.main.access$000(main.java:17)
at b4a.example.main$WaitForLayout.run(main.java:80)
at android.os.Handler.handleCallback(Handler.java:615)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4745)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)




I'm add B4A library, B4A project and the original Java library if someone has the time to help me where I'm wrong!
 

Attachments

  • SerialJAB.zip
    7.6 KB · Views: 243
  • Additional.zip
    6.7 KB · Views: 223
  • serialDWIN.zip
    6.3 KB · Views: 220
Top