我创建了一个android应用程序,在另一个Android应用程序中用作库。我在android应用程序中使用了一些第三方jar作为库。当我在我的Android应用程序中链接这个库并运行它时,我在尝试访问库中的类时遇到验证错误。我可以知道这里阻止的问题是什么?任何帮助非常感谢..
我在这里附加了日志,Parser1是库中的类。当我尝试为Parser1类创建对象时,我在行中收到错误。
06-06 10:05:43.742: WARN/dalvikvm(224): VFY: unable to resolve static method 3084: Lorg/codehaus/jackson/JsonToken;.values ()[Lorg/codehaus/jackson/JsonToken;
06-06 10:05:43.742: DEBUG/dalvikvm(224): VFY: replacing opcode 0x71 at 0x0005
06-06 10:05:43.742: DEBUG/dalvikvm(224): Making a copy of Lcom/support/utils/Parser1;.$SWITCH_TABLE$org$codehaus$jackson$JsonToken code (522 bytes)
06-06 10:05:43.752: WARN/dalvikvm(224): VFY: unable to find class referenced in signature (Lorg/codehaus/jackson/JsonParser;)
06-06 10:05:43.752: INFO/dalvikvm(224): Could not find method org.codehaus.jackson.JsonParser.getCurrentToken, referenced from method com.support.utils.Parser1.addSectionContentData
06-06 10:05:43.761: WARN/dalvikvm(224): VFY: unable to resolve virtual method 3077: Lorg/codehaus/jackson/JsonParser;.getCurrentToken ()Lorg/codehaus/jackson/JsonToken;
06-06 10:05:43.761: DEBUG/dalvikvm(224): VFY: replacing opcode 0x74 at 0x0002
06-06 10:05:43.761: DEBUG/dalvikvm(224): Making a copy of Lcom/support/utils/Parser1;.addSectionContentData code (2421 bytes)
06-06 10:05:43.761: WARN/dalvikvm(224): VFY: unable to resolve exception class 685 (Lorg/codehaus/jackson/JsonParseException;)
06-06 10:05:43.771: WARN/dalvikvm(224): VFY: unable to resolve exception class 685 (Lorg/codehaus/jackson/JsonParseException;)
06-06 10:05:43.771: WARN/dalvikvm(224): VFY: unable to resolve exception class 685 (Lorg/codehaus/jackson/JsonParseException;)
06-06 10:05:43.771: WARN/dalvikvm(224): VFY: unable to find exception handler at addr 0x19b
06-06 10:05:43.771: WARN/dalvikvm(224): VFY: rejected Lcom/support/utils/Parser1;.addSectionContentData (Lorg/codehaus/jackson/JsonParser;Ljava/util/List;Lcom/support/ModelClasses/SectionContent;Lcom/support/ModelClasses/FeatureInfo;ZZLjava/lang/String;)Ljava/util/List;
06-06 10:05:43.781: WARN/dalvikvm(224): VFY: rejecting opcode 0x0d at 0x019b
06-06 10:05:43.781: WARN/dalvikvm(224): VFY: rejected Lcom/support/utils/Parser1;.addSectionContentData (Lorg/codehaus/jackson/JsonParser;Ljava/util/List;Lcom/support/ModelClasses/SectionContent;Lcom/support/ModelClasses/FeatureInfo;ZZLjava/lang/String;)Ljava/util/List;
06-06 10:05:43.781: WARN/dalvikvm(224): Verifier rejected class Lcom/support/utils/Parser1;
06-06 10:05:43.793: WARN/dalvikvm(224): threadid=15: thread exiting with uncaught exception (group=0x4001b188)
06-06 10:05:43.793: ERROR/AndroidRuntime(224): Uncaught handler: thread AsyncTask #1 exiting due to uncaught exception
06-06 10:05:43.812: ERROR/AndroidRuntime(224): java.lang.RuntimeException: An error occured while executing doInBackground()
06-06 10:05:43.812: ERROR/AndroidRuntime(224): at android.os.AsyncTask$3.done(AsyncTask.java:200)
06-06 10:05:43.812: ERROR/AndroidRuntime(224): at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273)
06-06 10:05:43.812: ERROR/AndroidRuntime(224): at java.util.concurrent.FutureTask.setException(FutureTask.java:124)
06-06 10:05:43.812: ERROR/AndroidRuntime(224): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307)
06-06 10:05:43.812: ERROR/AndroidRuntime(224): at java.util.concurrent.FutureTask.run(FutureTask.java:137)
06-06 10:05:43.812: ERROR/AndroidRuntime(224): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1068)
06-06 10:05:43.812: ERROR/AndroidRuntime(224): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:561)
06-06 10:05:43.812: ERROR/AndroidRuntime(224): at java.lang.Thread.run(Thread.java:1096)
06-06 10:05:43.812: ERROR/AndroidRuntime(224): Caused by: java.lang.VerifyError: com.support.utils.Parser1
06-06 10:05:43.812: ERROR/AndroidRuntime(224): at com.Sample.checkforversioning(Sample.java:652)
06-06 10:05:43.812: ERROR/AndroidRuntime(224): at com.Sample$checkVersionThread.doInBackground(Sample.java:682)
06-06 10:05:43.812: ERROR/AndroidRuntime(224): at com.Sample$checkVersionThread.doInBackground(Sample.java:1)
06-06 10:05:43.812: ERROR/AndroidRuntime(224): at android.os.AsyncTask$2.call(AsyncTask.java:185)
06-06 10:05:43.812: ERROR/AndroidRuntime(224): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
06-06 10:05:43.812: ERROR/AndroidRuntime(224): ... 4 more
06-06 10:05:43.832: INFO/Process(52): Sending signal. PID: 224 SIG: 3
谢谢, Senthil.M
答案 0 :(得分:11)
在Eclipse
中,转到Project properties -> Java Build Path
。选择Order and Export
标签并检查您的第三方广告。
答案 1 :(得分:2)
这可能是因为jar中的某些东西在Java中访问了Android SDK中没有的内容。在LogCat中查找异常,它可能会告诉您缺少的内容。如果您有第三方jar的来源,请尝试将它们直接包含在您的项目中;这将有助于解决问题。
您还需要通过sdk附带的“dx”工具运行您的jar文件。
答案 2 :(得分:0)
如果您使用的是ant,那么您应该将所有外部jar添加到以下目录“libs”中,并在新文件中添加以下行:ant.properties: jar.libs.dir =库
答案 3 :(得分:0)
如果您在使用ProGuard构建应用发布版本后获得VerifyError
,则可能与某些优化问题有关。 Refer to the documentation,主要建议使用-dontoptimize
禁用优化。
答案 4 :(得分:0)
从/ libs文件夹中删除所有jar文件,然后再次添加它们,然后清理项目并为我修复它。
答案 5 :(得分:0)
同样的错误发生在我身上,因为我试图在v.8 API设备上捕获异常SQLDataException,因为相应的类不包含在v.8 API中(错误没有发生在v.14设备中,其中该课程包括在内)。 实际上,SQLDataException.class不仅存在于v.8 API的android.jar中,而是包含在v.14 API中。 所以我用异常SQLException(其SQLDataException是一个子类)替换异常SQLDataException,我的应用程序现在可以在两个API的设备上正常运行。