gpt4 book ai didi

java - Android 意外的顶级异常和验证错误

转载 作者:太空宇宙 更新时间:2023-11-04 14:43:51 25 4
gpt4 key购买 nike

我正在尝试组合一个 Android 应用程序,该应用程序使用一个使用 IKVM 的库,因此我需要包含 mscorlib.jar。问题是这样的。当我将 mscorlib.jar 添加为模块依赖项(使用 Intellij)时,我收到下面的意外顶级异常,该异常来自此处的帖子 Android Studio - UNEXPECTED TOP-LEVEL EXCEPTION:意味着该库被多次包含。

Information:0 warnings
Error:Android Pre Dex: [mscorlib.jar] UNEXPECTED TOP-LEVEL EXCEPTION:
Error:Android Pre Dex: [mscorlib.jar] com.android.dex.util.ExceptionWithContext: name already added: string{"XmlNamespace"}
Error:Android Pre Dex: [mscorlib.jar] at com.android.dex.util.ExceptionWithContext.withContext(ExceptionWithContext.java:45)
Error:Android Pre Dex: [mscorlib.jar] at com.android.dx.dex.cf.CfTranslator.translate(CfTranslator.java:97)
Error:Android Pre Dex: [mscorlib.jar] at com.android.dx.command.dexer.Main.processClass(Main.java:682)
Error:Android Pre Dex: [mscorlib.jar] at com.android.dx.command.dexer.Main.processFileBytes(Main.java:634)
Error:Android Pre Dex: [mscorlib.jar] at com.android.dx.command.dexer.Main.access$600(Main.java:78)
Error:Android Pre Dex: [mscorlib.jar] at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:572)
Error:Android Pre Dex: [mscorlib.jar] at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:284)
Error:Android Pre Dex: [mscorlib.jar] at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:166)
Error:Android Pre Dex: [mscorlib.jar] at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)
Error:Android Pre Dex: [mscorlib.jar] at com.android.dx.command.dexer.Main.processOne(Main.java:596)
Error:Android Pre Dex: [mscorlib.jar] at com.android.dx.command.dexer.Main.processAllFiles(Main.java:498)
Error:Android Pre Dex: [mscorlib.jar] at com.android.dx.command.dexer.Main.runMonoDex(Main.java:264)
Error:Android Pre Dex: [mscorlib.jar] at com.android.dx.command.dexer.Main.run(Main.java:230)
Error:Android Pre Dex: [mscorlib.jar] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
Error:Android Pre Dex: [mscorlib.jar] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
Error:Android Pre Dex: [mscorlib.jar] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
Error:Android Pre Dex: [mscorlib.jar] at java.lang.reflect.Method.invoke(Method.java:606)
Error:Android Pre Dex: [mscorlib.jar] at org.jetbrains.android.compiler.tools.AndroidDxRunner.runDex(AndroidDxRunner.java:161)
Error:Android Pre Dex: [mscorlib.jar] at org.jetbrains.android.compiler.tools.AndroidDxRunner.main(AndroidDxRunner.java:294)
Error:Android Pre Dex: [mscorlib.jar] at com.intellij.rt.execution.CommandLineWrapper.main(CommandLineWrapper.java:121)
Error:Android Pre Dex: [mscorlib.jar] Caused by: java.lang.IllegalArgumentException: name already added: string{"XmlNamespace"}
Error:Android Pre Dex: [mscorlib.jar] at com.android.dx.rop.annotation.Annotation.add(Annotation.java:208)
Error:Android Pre Dex: [mscorlib.jar] at com.android.dx.dex.cf.AttributeTranslator.translateAnnotationDefaults(AttributeTranslator.java:413)
Error:Android Pre Dex: [mscorlib.jar] at com.android.dx.dex.cf.AttributeTranslator.getClassAnnotations(AttributeTranslator.java:135)
Error:Android Pre Dex: [mscorlib.jar] at com.android.dx.dex.cf.CfTranslator.translate0(CfTranslator.java:129)
Error:Android Pre Dex: [mscorlib.jar] at com.android.dx.dex.cf.CfTranslator.translate(CfTranslator.java:94)
Error:Android Pre Dex: [mscorlib.jar] ... 22 more
Error:Android Pre Dex: [mscorlib.jar] ...while processing cli/System/Runtime/Remoting/Metadata/SoapTypeAttribute$Annotation.class
Error:Android Pre Dex: [mscorlib.jar] 1 error; aborting

如果我删除它,项目会编译,但当应用程序的部分实际调用使用 IKVM 的库时,我会在运行时收到验证错误(如下)。它表示找不到 mscorlib.jar 中定义的异常处理程序。

07-09 19:02:11.087    1979-1979/net.windward.SimpleAndroidApp W/dalvikvm﹕ VFY: unable to resolve exception class 1139 (Lcli/System/Exception;)
07-09 19:02:11.097 1979-1979/net.windward.SimpleAndroidApp W/dalvikvm﹕ VFY: unable to find exception handler at addr 0x1f0
07-09 19:02:11.097 1979-1979/net.windward.SimpleAndroidApp W/dalvikvm﹕ VFY: rejected Lnet/windward/xmlreport/KZ;.factory (Ljava/io/InputStream;Lnet/windward/tags/BaseTag;ILjava/io/InputStream;I)Lnet/windward/document/element/ElementPict;
07-09 19:02:11.097 1979-1979/net.windward.SimpleAndroidApp W/dalvikvm﹕ VFY: rejecting opcode 0x0d at 0x01f0
07-09 19:02:11.097 1979-1979/net.windward.SimpleAndroidApp W/dalvikvm﹕ VFY: rejected Lnet/windward/xmlreport/KZ;.factory (Ljava/io/InputStream;Lnet/windward/tags/BaseTag;ILjava/io/InputStream;I)Lnet/windward/document/element/ElementPict;
07-09 19:02:11.097 1979-1979/net.windward.SimpleAndroidApp W/dalvikvm﹕ Verifier rejected class Lnet/windward/xmlreport/KZ;
07-09 19:02:11.097 1979-1979/net.windward.SimpleAndroidApp D/AndroidRuntime﹕ Shutting down VM
07-09 19:02:11.097 1979-1979/net.windward.SimpleAndroidApp W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0xb2ccbb20)
07-09 19:02:11.117 1979-1979/net.windward.SimpleAndroidApp E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: net.windward.SimpleAndroidApp, PID: 1979
java.lang.IllegalStateException: Could not execute method of the activity
at android.view.View$1.onClick(View.java:3823)
at android.view.View.performClick(View.java:4438)
at android.view.View$PerformClick.run(View.java:18422)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5017)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at android.view.View$1.onClick(View.java:3818)
            at android.view.View.performClick(View.java:4438)
            at android.view.View$PerformClick.run(View.java:18422)
            at android.os.Handler.handleCallback(Handler.java:733)
            at android.os.Handler.dispatchMessage(Handler.java:95)
            at android.os.Looper.loop(Looper.java:136)
            at android.app.ActivityThread.main(ActivityThread.java:5017)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:515)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
            at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.VerifyError: net/windward/xmlreport/KZ
at net.windward.xmlreport.ProcessReport.processData(Unknown Source)
at net.windward.SimpleAndroidApp.MyActivity.sendMessage(MyActivity.java:62)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:515)
            at android.view.View$1.onClick(View.java:3818)
            at android.view.View.performClick(View.java:4438)
            at android.view.View$PerformClick.run(View.java:18422)
            at android.os.Handler.handleCallback(Handler.java:733)
            at android.os.Handler.dispatchMessage(Handler.java:95)
            at android.os.Looper.loop(Looper.java:136)
            at android.app.ActivityThread.main(ActivityThread.java:5017)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:515)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
            at dalvik.system.NativeStart.main(Native Method)

因此,第一个错误似乎包含了两次 mscorlib.jar,但第二个错误则表明它根本不包含在内。我倾向于第一个错误不是由于包含两次而导致的,因为我一生都找不到它在除了它所属的模块依赖项之外的任何地方列为依赖项或库。

有人遇到过这种情况吗?

最佳答案

关于android sdk级别

  <uses-sdk
android:minSdkVersion="9"
android:targetSdkVersion="19" />

检查 androidManifest 中的 sdk 级别和 ide API 级别。

关于java - Android 意外的顶级异常和验证错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24665478/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com