stupid VerifyError

Put your problem here if it does not fit any of the other categories.

stupid VerifyError

Postby anarche » Tue May 18, 2010 5:25 am

Ok so I'm getting this:

Code: Select all
05-18 13:59:37.248: ERROR/AndroidRuntime(9027): java.lang.VerifyError: com.skooter.shiftroster.ShiftRoster
05-18 13:59:37.248: ERROR/AndroidRuntime(9027):     at java.lang.Class.newInstanceImpl(Native Method)
05-18 13:59:37.248: ERROR/AndroidRuntime(9027):     at java.lang.Class.newInstance(Class.java:1472)
05-18 13:59:37.248: ERROR/AndroidRuntime(9027):     at android.app.Instrumentation.newActivity(Instrumentation.java:1097)
05-18 13:59:37.248: ERROR/AndroidRuntime(9027):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2316)
05-18 13:59:37.248: ERROR/AndroidRuntime(9027):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2417)
05-18 13:59:37.248: ERROR/AndroidRuntime(9027):     at android.app.ActivityThread.access$2100(ActivityThread.java:116)
05-18 13:59:37.248: ERROR/AndroidRuntime(9027):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1794)
05-18 13:59:37.248: ERROR/AndroidRuntime(9027):     at android.os.Handler.dispatchMessage(Handler.java:99)
05-18 13:59:37.248: ERROR/AndroidRuntime(9027):     at android.os.Looper.loop(Looper.java:123)
05-18 13:59:37.248: ERROR/AndroidRuntime(9027):     at android.app.ActivityThread.main(ActivityThread.java:4203)
05-18 13:59:37.248: ERROR/AndroidRuntime(9027):     at java.lang.reflect.Method.invokeNative(Native Method)
05-18 13:59:37.248: ERROR/AndroidRuntime(9027):     at java.lang.reflect.Method.invoke(Method.java:521)
05-18 13:59:37.248: ERROR/AndroidRuntime(9027):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791)
05-18 13:59:37.248: ERROR/AndroidRuntime(9027):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:549)
05-18 13:59:37.248: ERROR/AndroidRuntime(9027):     at dalvik.system.NativeStart.main(Native Method)


which I gather is being caused by the missing
Code: Select all
05-18 13:59:37.098: WARN/dalvikvm(9027): VFY: unable to resolve static method 137: Lcom/skooter/android/tools/SQLText;.encode (Ljava/lang/String;)Ljava/lang/String;


the SQLText.encode method is in a separate project in eclipse that is being imported as a Jarfile.

I've tried importing as jarfile, importing classes. The Build Path has the jar on the Build and Export list and nothing seems to work

Has anyone solved this problem?
anarche
Master Developer
Master Developer
 
Posts: 369
Joined: Sun Apr 11, 2010 5:21 am

Top

Re: stupid VerifyError

Postby nicholas.hauschild » Tue May 18, 2010 6:00 am

Hello anarche,

I am NOT 100% sure on this...

Being that you are using a third party library, which was likely written for JavaSE, you may run into compatibility issues, especially if the method you are trying to use is a native method.

You may have to come up with your own implementation on this one...

Good Luck!
-Nick
nicholas.hauschild
Master Developer
Master Developer
 
Posts: 310
Joined: Fri Dec 04, 2009 4:50 am

Re: stupid VerifyError

Postby anarche » Tue May 18, 2010 6:12 am

Thanks for the reply.

The 3rd-party toolkit is one that I've written: a collection of classes that will probably be reused across various Android projects. They were created in eclipse the standard "New Android Project" way, then exported as a jarfile
anarche
Master Developer
Master Developer
 
Posts: 369
Joined: Sun Apr 11, 2010 5:21 am

Re: stupid VerifyError

Postby nicholas.hauschild » Tue May 18, 2010 1:19 pm

Well, in that case, I do not know exactly how you included the .jar, but from the Android Developer Guide, I have found this:

Adding an External Library (.jar) using Eclipse

You can use a third party JAR in your application by adding it to your Eclipse project as follows:

1. In the Package Explorer panel, right-click on your project and select Properties.
2. Select Java Build Path, then the tab Libraries.
3. Press the Add External JARs... button and select the JAR file.

Alternatively, if you want to include third party JARs with your package, create a new directory for them within your project and select Add Library... instead.

It is not necessary to put external JARs in the assets folder.


Hope this helps!
-Nick

from here... http://developer.android.com/guide/appendix/faq/commontasks.html#addexternallibrary
nicholas.hauschild
Master Developer
Master Developer
 
Posts: 310
Joined: Fri Dec 04, 2009 4:50 am

Re: stupid VerifyError

Postby anarche » Tue May 18, 2010 2:25 pm

Yep done that.

From what I can gather, standard jarfiles can't be imported int o android apps because the Davlik virtual machine uses its own bytecode, rather than the standard Java bytecode, and the dx tool needs to be used to import jarfiles.

Does anybody have any experience with the dx tool, coz I can't seem to get it to work
anarche
Master Developer
Master Developer
 
Posts: 369
Joined: Sun Apr 11, 2010 5:21 am

Re: stupid VerifyError

Postby kec6227 » Tue May 18, 2010 3:09 pm

I have successfully included jar files in my projects, and I am guessing that your jar file is accessing something not available in the android SDK. Android doesn't use a standard set of classes (like JavaSE) and has customized all the components it includes.

Try copying all the code directly into an android project, rather than importing the jar. This will probably tell you where the problem is more precisely. If it is trying to access a method not available to Java, then you should find it this way.

As an additional note, you should not import anything that includes Java core classes - this is bad! If you try, eclipse will warn you about it, giving you the option to override; although you shouldn't.
kec6227
Developer
Developer
 
Posts: 30
Joined: Fri Jul 24, 2009 7:31 pm

Top

Re: stupid VerifyError

Postby anarche » Wed May 19, 2010 12:22 am

Well, the import of the source code worked, which makes sense since the code was originally part of the project in the first place.

Importing the Jar still didn't work. Also the errors tab kept complaining about a missing Gen dir in AndroidToolkit - which was indeed missing.

Is the Gen dir needed? How do I ensure it is exported to the Jar? I've double checked that it is checked...
anarche
Master Developer
Master Developer
 
Posts: 369
Joined: Sun Apr 11, 2010 5:21 am

Re: stupid VerifyError

Postby johnhunsley » Tue Nov 09, 2010 1:03 am

Hi,

I have successfully imported 3rd party jars into an Android project.

The key to doing this is running the adb dex parser on compiled classes within the jar you want to include. I created a maven build file which converts the classes into classes.dex using the adb dex tool.

The build file does the following

1. references the 3rd party jar you want to include as a dependency, just like any maven pom.xml
2. copies the dependencies into the project
3. unpacks them and puts everything into an output file
4. generates the R class
5. runs the adb dex parser over all compiled classes
6. zips up the dex classes, resources and manifest into a .apk file ready to deploy to the emulator or phone by running adb install

Give me a shout if you want to see the pom.xml
[url]http://www.browsershell.com[/url]
johnhunsley
Freshman
Freshman
 
Posts: 8
Joined: Mon Jan 19, 2009 9:30 am

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 14 guests