Android 2.0 之前版本中的 JTwitter verifyError
我正在尝试将 JTwitter 集成到 Android 应用程序中,直到我决定在旧 Android 版本上进行回归测试之前,我已经完全成功。在 Android 2.x 中,我的代码工作得很好,但在 Android 1.5/1.6 中,Dalvik 在以下行中抛出了一个VerifyError:
OAuthSignpostClient oauthClient
= new OAuthSignpostClient(KEY_TWITTER, SECRET_TWITTER, "oob");
并提供了这个 logcat 输出和堆栈跟踪:
Could not find method javax.swing.JOptionPane.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)
我试图找出底层实现中可能发生的变化会影响此问题的 Android 版本以及解决方法可能是什么? 类似的问题不久前得到了回答,但答案是现在已失效的链接的形式到论坛帖子。
有什么想法吗?
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.JOptionPane.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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在 Android 2.0 之前,当出现问题时,验证器会立即拒绝类。在 2.0 及更高版本中,某些故障的报告会推迟到代码实际执行时才报告。尝试调用不存在或不可访问的方法就是一种这样的情况。
这是验证者行为发生变化的示例。即使您没有调用不存在的函数,尝试调用它的整个类也会被拒绝。
可以在此处找到一些解决方法,但听起来您已经找到了一个靠你自己。
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.