Java Question Unable to Create New Class Object from Wrapper

johnv727

Member
Licensed User
Longtime User
I've been working on implementing an existing java connector for the EMC Atmos API for cloud storage into B4A. Here is the link to it:
https://code.google.com/p/atmos-java/
I'm using the deprecated EsuRestApi since the newest version is currently incompatible with android.

I have managed to get the library to work through a simple Android application using only java but when implementing the jar file to b4a, it won't work using the exact same code. I understand HTTP connections must be done on separate threads in Android and basic4android has its own submitrunnable method to run the threads and I've tried it all.

The app gets hung up here when running the method to initialize the EsuRestApi class object:
B4X:
       try{
            api = new EsuRestApi(host, port, uid, secret);
        } catch(EsuException ex) {

        }
Now, if I implement the source code directly for the java connector(which is how I got my simple java android app to work), this is the error I get:
java.lang.VerifyError: com/emc/esu/api/rest/EsuRestApi

If I use the jar file for it, I get no errors. It is like the moment the code gets to that line of code, the code just stops altogether.

Using my little java app, I can run this line of code initializing the api object on the main thread since its not actually making a connection but no matter what I do, I can't get past that line in basic4android. Anyone have any ideas on why this is?
 

johnv727

Member
Licensed User
Longtime User
ERROR/AndroidRuntime(8344): FATAL EXCEPTION: Thread-74258
java.lang.VerifyError: com/emc/esu/api/rest/EsuRestApi
at anywheresoftware.b4a.AtmosCloud.AtmosCloud$Actions.Initialize(AtmosCloud.java:234)
at anywheresoftware.b4a.AtmosCloud.AtmosCloud$Actions$1.run(AtmosCloud.java:172)
at java.lang.Thread.run(Thread.java:856)

This is what I get running it by just creating a standard runnable and running it with a Thread object. I get the same no matter which method I try running it on a separate thread. Even if it wasn't on a separate thread, it should still simply create the object. On my test app that is java, I had no problem creating the object on the main thread. I would only get the NetworkOnMain exception if I tried doing some sort of connection to the Atmos server.

Note: This was without catching the exception. Notice its the same error. Does B4A automatically catch the exceptions?
 
Last edited:

agraham

Expert
Licensed User
Longtime User
Cop out suggestion. I gather you are compiling the source into your library and it is failing at runtime whereas the original jar works.

The VerifyError exception seems a bit obscure but I fount this comment
VerifyError has a few different causes, mostly stemming from a bad set
of bytecode -- something existed at compile time that does not exist
at run time.
Looks like compiling the source in Eclipse does something different to what's in the original jar. Have you thought of just referencing the original jar in your library using @DependsOn?
 

johnv727

Member
Licensed User
Longtime User
Well, the thing is, I implemented all the source code from the jar file directly into my project so its not even using the jar file. It does still depend on the libraries the original jar file was dependent on but I made sure to include all of them into the jar file in a lib folder all properly referenced. I've even tested them out with jar files to be used on nonandroid programs to be sure that I'm doing it correctly. And I've made sure to compile with java 6 compliance. That was one of the first things I made sure of.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…