开发者

JTwitter VerifyError in Android pre-2.0

I'm attempting to integrate JTwitter into an Android application, and I have been completely successful up until the point where I decided to regression test on older Android versions. In Android 2.x my code works great, but in Android 1.5/1.6 Dalvik throws a VerifyError on the following line:

OAuthSignpostClient oauthClient
        = new OAuthSignpostClient(KEY_TWITTER, SECRET_TWITTER, "oob");

and provides this logcat output and stack trace:

Could not find method javax.swing.JOptionP开发者_如何学编程ane.showInputDialog, referenced from method winterwell.jtwitter.OAuthSignpostClient.askUser
VFY: unable to resolve static method 1703: Ljavax/swing/JOptionPane;.showInputDialog (Ljava/lang/Object;)Ljava/lang/String;
VFY:  rejecting opcode 0x71 at 0x0000
VFY:  rejected Lwinterwell/jtwitter/OAuthSignpostClient;.askUser (Ljava/lang/String;)Ljava/lang/String;
Verifier rejected class Lwinterwell/jtwitter/OAuthSignpostClient;
Shutting down VM
threadid=3: thread exiting with uncaught exception (group=0x4001aa28)
Uncaught handler: thread main exiting due to uncaught exception
java.lang.VerifyError: winterwell.jtwitter.OAuthSignpostClient
  at com.wirelessdesigns.android.AuthActivity.onCreate(AuthActivity.java:37)
  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1123)
  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2364)
  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2417)
  at android.app.ActivityThread.access$2100(ActivityThread.java:116)
  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1794)
  at android.os.Handler.dispatchMessage(Handler.java:99)
  at android.os.Looper.loop(Looper.java:123)
  at android.app.ActivityThread.main(ActivityThread.java:4203)
  at java.lang.reflect.Method.invokeNative(Native Method)
  at java.lang.reflect.Method.invoke(Method.java:521)
  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791)
  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:549)
  at dalvik.system.NativeStart.main(Native Method)

I'm trying to figure out what may have changed in the underlying implementation between the Android versions that would affect this and what the workaround might be? A similar question was answered a while back, but the answer was in the form of a now-dead link to a forum post.

Any thoughts?


Before Android 2.0, the verifier would immediately reject classes when something wasn't right. In 2.0 and later, reporting of certain failures is deferred until the code is actually executed. Attempting to call a nonexistent or inaccessible method is one such case.

This is an example of why the verifier behavior was changed. Even though you're not calling the absent function, the whole class that's trying to call it is getting rejected.

Some workarounds can be found here, but it sounds like you've found one on your own.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜