我试图整理一个使用IKVM的Android应用程序,因此我需要包含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包含两次,但第二个错误似乎根本不包括在内。我倾向于第一个错误而不是因为包括两次,因为我不能在我的生活中发现它被列为依赖项或库,除了它所属的模块依赖项。
以前有人遇到过这个吗?
答案 0 :(得分:0)
关于android sdk级别
<uses-sdk
android:minSdkVersion="9"
android:targetSdkVersion="19" />
检查androidManifest和ide API级别的sdk级别。