Java Question Could not find method

qle

Member
Licensed User
Longtime User
Hi,

Im tying to create a library from my suppliers SDK
This SDK i can compile and run in Eclipse Project without any issues.

Im trying to create a wrapper for B4A (which i have done for other SDK's)
but im having a few problems with this one..

The SDK uses 3 libraries under the /lib folder
/lib/android-support-v4.jar
/lib/DeviceAPI.jar
/libs/armeabi/libDeviceAPI.so
I have confirmed these are in the File.DirInternal directory of the project when running

The .jar in the lib folder seem to be loaded by
import com.rscja.deviceapi.Barcode1D;
import com.rscja.deviceapi.exception.ConfigurationException;

(in my java wrapper)​
I use
System.load(File.Combine(File.getDirInternal(), "libDeviceAPI.so"));
(in my java wrapper)​
To load the Library.. but should i? does the import take care of the load? (im not sure)

I have cut my A4b Project to bare minimum for testing and this post,
All my AB4 Project has is the DIM statement to the library class
(ie: dim c as c4000, where c4000 is my library)

When i launch my AB4 app, In the logcat i see
B4X:
D/dalvikvm(16532): threadid=11: interp stack at 0x4df55000[/INDENT]
D/dalvikvm(16532): threadid=11: calling run()
I/dalvikvm(16532): Could not find method com.rscja.deviceapi.Barcode1D.getInstance, referenced from method com.android.barcode1d.c4000.init
W/dalvikvm(16532): VFY: unable to resolve static method 1951: Lcom/rscja/deviceapi/Barcode1D;.getInstance ()Lcom/rscja/deviceapi/Barcode1D;
D/dalvikvm(16532): VFY: replacing opcode 0x71 at 0x0002
note: .getInstance is referenced within a class in my wrapper, but not called (yet)

This seems to be at the point of the 'dim c as c4000' statement in AB4 project..
and seems to be Before Activity_Create in AB4

Needless to say, the AB4 project fails with errors..
but for now i think i need to sort out the above issue before i move on to the next issue.

i hope this i understandable, im not that good at java.

Any help is very much appreciated

Lee.​
 
Last edited:

DonManfred

Expert
Licensed User
Longtime User
android-support-v4.jar
DeviceAPI.jar
I have confirmed these are in the File.DirInternal directory of the project when running
The two files above need to be placed in your AdditionalLibs-folder you set in the IDE.

The .so will be part of the generated jar when compiling a java-library.
The jar and xml need to be placed in AdditionalLibs too.
 

qle

Member
Licensed User
Longtime User
Thank you for the reply.

The jar and the xml that i created in Eclipse (and i have also tried creating the library using the SLC tool)
i then put the created xml and jar library into the AdditionalLibs folder.
The library is then accessible by the A4B IDE.

Is this what you mean?
The issue is that i get Could not find method com.rscja.deviceapi.Barcode1D.getInstance (viewed in the logcat)
when the B4A app runs.. (but it gets this error even before it hit the A4B Activity_Create())

Lee.
 

DonManfred

Expert
Licensed User
Longtime User
i then put the created xml and jar library into the AdditionalLibs folder.
But i think the referenced JARs will not be part of the generated jar. You maybe need to add a dependson directive in your java-code to tell b4a that the jar xyz is needed. This jar (in your case probably the DeviceAPI.jar) will not be part of the generated jar but you must place the file in your additional libraries folder. Same for the android-support-v4.jar; but as the error states it looks not like an missing support-jar
 

DonManfred

Expert
Licensed User
Longtime User
to be more precise:

- check if you have set a dependson directive in your java code. It should look like this
B4X:
@DependsOn(values={"DeviceAPI"})
Please note that you need to add
B4X:
import anywheresoftware.b4a.BA.DependsOn;
to your imports...

- check if the file DeviceAPI.jar is copied to your additional-libraries folder (additional to your generated jar and xml-files!)
- try to compile again
 
  • Like
Reactions: qle

qle

Member
Licensed User
Longtime User
Thank you Manfred,

By adding the dependson in the java code
and then dropping the DeviceAPI.jar into the A4B <progam files>/Anywhere Software\Basic4android\Libraries
resolved the missing method, and i was able to call the .getInstance without error.

Brilliant, thank you again.

a step closer!!

Now the next issue i have hit... but for now i will try an nut it out myself. (if i cant, then i will create a new thread)

Lee.
 
Top