【问题标题】:Android studio on windows 7 error :UNEXPECTED TOP-LEVEL EXCEPTIONWindows 7 上的 Android Studio 错误:UNEXPECTED TOP-LEVEL EXCEPTION
【发布时间】:2015-10-04 20:45:01
【问题描述】:

导入osmand项目时出错:

Error:Execution failed for task ':OsmAnd:preDexFreeLegacyArmv5Debug'.

com.android.ide.common.internal.LoggedErrorException:无法运行命令: E:\Android\sdk\build-tools\21.1.2\dx.bat --dex --force-jumbo --output E:\Android_test_projects\Osmand-master2\Osmand-master\OsmAnd\build\intermediates\pre- dexed\freelegacyarmv5\debug\OsmAnd-java-android-9c283cd307dbfef07359ccbde68a116b21ff0b4f.jar E:\Android_test_projects\Osmand-master2\Osmand-master\OsmAnd-java\build\libs\OsmAnd-java-android.jar 错误代码: 1 输出: 意外的顶级异常: com.android.dx.cf.iface.ParseException:坏类文件魔术(cafebabe)或版本(0034.0000) 在 com.android.dx.cf.direct.DirectClassFile.parse0(DirectClassFile.java:472) 在 com.android.dx.cf.direct.DirectClassFile.parse(DirectClassFile.java:406) 在 com.android.dx.cf.direct.DirectClassFile.parseToInterfacesIfNecessary(DirectClassFile.java:388) 在 com.android.dx.cf.direct.DirectClassFile.getMagic(DirectClassFile.java:251) 在 com.android.dx.command.dexer.Main.processClass(Main.java:704) 在 com.android.dx.command.dexer.Main.processFileBytes(Main.java:673) 在 com.android.dx.command.dexer.Main.access$300(Main.java:83) 在 com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:602) 在 com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:284) 在 com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:166) 在 com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144) 在 com.android.dx.command.dexer.Main.processOne(Main.java:632) 在 com.android.dx.command.dexer.Main.processAllFiles(Main.java:510) 在 com.android.dx.command.dexer.Main.runMonoDex(Main.java:280) 在 com.android.dx.command.dexer.Main.run(Main.java:246) 在 com.android.dx.command.dexer.Main.main(Main.java:215) 在 com.android.dx.command.Main.main(Main.java:106) ...同时解析 com/google/protobuf/AbstractMessage$1.class 1个错误;中止

上述错误的原因是java 1.8。将其更改为 1.7 后,我得到了这个运行时错误

      2-11 10:28:55.160  26327-26327/net.osmand V/Zygote﹕ Switching descriptor 34 to /dev/null
02-11 10:28:55.160  26327-26327/net.osmand V/Zygote﹕ Switching descriptor 9 to /dev/null
02-11 10:28:55.160  26327-26327/net.osmand D/dalvikvm﹕ Late-enabling CheckJNI
02-11 10:28:55.200  26327-26327/net.osmand D/ActivityThread﹕ handleBindApplication:net.osmand
02-11 10:28:55.200  26327-26327/net.osmand D/ActivityThread﹕ setTargetHeapUtilization:0.75
02-11 10:28:55.200  26327-26327/net.osmand D/ActivityThread﹕ setTargetHeapMinFree:2097152
02-11 10:28:55.260  26327-26327/net.osmand I/net.osmand﹕ ResourceManager Tiles to load in memory : 162.0
02-11 10:28:55.350  26327-26327/net.osmand D/AndroidRuntime﹕ Shutting down VM
02-11 10:28:55.350  26327-26327/net.osmand W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0x41653db8)
02-11 10:28:55.350  26327-26327/net.osmand E/AndroidRuntime﹕ FATAL EXCEPTION: main
    Process: net.osmand, PID: 26327
    java.lang.RuntimeException: Unable to create application net.osmand.plus.OsmandApplication: java.lang.IllegalStateException: java.lang.IllegalArgumentException: is == null
            at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4476)
            at android.app.ActivityThread.access$1500(ActivityThread.java:144)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1265)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:136)
            at android.app.ActivityThread.main(ActivityThread.java:5146)
            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:796)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:612)
            at dalvik.system.NativeStart.main(Native Method)
     Caused by: java.lang.IllegalStateException: java.lang.IllegalArgumentException: is == null
            at net.osmand.router.RoutingConfiguration.getDefault(RoutingConfiguration.java:171)
            at net.osmand.plus.helpers.AvoidSpecificRoads.getBuilder(AvoidSpecificRoads.java:44)
            at net.osmand.plus.helpers.AvoidSpecificRoads.<init>(AvoidSpecificRoads.java:38)
            at net.osmand.plus.OsmandApplication.onCreate(OsmandApplication.java:165)
            at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1007)
            at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4473)
            at android.app.ActivityThread.access$1500(ActivityThread.java:144)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1265)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:136)
            at android.app.ActivityThread.main(ActivityThread.java:5146)
            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:796)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:612)
            at dalvik.system.NativeStart.main(Native Method)
     Caused by: java.lang.IllegalArgumentException: is == null
            at org.kxml2.io.KXmlParser.setInput(KXmlParser.java:1625)
            at net.osmand.router.RoutingConfiguration.parseFromInputStream(RoutingConfiguration.java:184)
            at net.osmand.router.RoutingConfiguration.getDefault(RoutingConfiguration.java:169)
            at net.osmand.plus.helpers.AvoidSpecificRoads.getBuilder(AvoidSpecificRoads.java:44)
            at net.osmand.plus.helpers.AvoidSpecificRoads.<init>(AvoidSpecificRoads.java:38)
            at net.osmand.plus.OsmandApplication.onCreate(OsmandApplication.java:165)
            at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1007)
            at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4473)
            at android.app.ActivityThread.access$1500(ActivityThread.java:144)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1265)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:136)
            at android.app.ActivityThread.main(ActivityThread.java:5146)
            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:796)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:612)
            at dalvik.system.NativeStart.main(Native Method)
        02-11 10:29:42.570  26327-26334/net.osmand D/dalvikvm﹕ null clazz in OP_INSTANCE_OF, single-stepping
        02-11 10:33:27.190  26327-26327/net.osmand I/Process﹕ Sending signal. PID: 26327 SIG: 9
        02-11 10:34:10.670  26873-26873/net.osmand D/ActivityThread﹕ handleBindApplication:net.osmand
        02-11 10:34:10.670  26873-26873/net.osmand D/ActivityThread﹕ setTargetHeapUtilization:0.75
        02-11 10:34:10.670  26873-26873/net.osmand D/ActivityThread﹕ setTargetHeapMinFree:2097152
        02-11 10:34:10.740  26873-26873/net.osmand I/net.osmand﹕ ResourceManager Tiles to load in memory : 162.0
        02-11 10:34:10.840  26873-26873/net.osmand D/AndroidRuntime﹕ Shutting down VM
        02-11 10:34:10.840  26873-26873/net.osmand W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0x41653db8)
        02-11 10:34:10.840  26873-26873/net.osmand E/AndroidRuntime﹕ FATAL EXCEPTION: main
            Process: net.osmand, PID: 26873
    java.lang.RuntimeException: Unable to create application net.osmand.plus.OsmandApplication: java.lang.IllegalStateException: java.lang.IllegalArgumentException: is == null
            at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4476)
            at android.app.ActivityThread.access$1500(ActivityThread.java:144)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1265)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:136)
            at android.app.ActivityThread.main(ActivityThread.java:5146)
            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:796)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:612)
            at dalvik.system.NativeStart.main(Native Method)
     Caused by: java.lang.IllegalStateException: java.lang.IllegalArgumentException: is == null
            at net.osmand.router.RoutingConfiguration.getDefault(RoutingConfiguration.java:171)
            at net.osmand.plus.helpers.AvoidSpecificRoads.getBuilder(AvoidSpecificRoads.java:44)
            at net.osmand.plus.helpers.AvoidSpecificRoads.<init>(AvoidSpecificRoads.java:38)
            at net.osmand.plus.OsmandApplication.onCreate(OsmandApplication.java:165)
            at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1007)
            at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4473)
            at android.app.ActivityThread.access$1500(ActivityThread.java:144)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1265)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:136)
            at android.app.ActivityThread.main(ActivityThread.java:5146)
            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:796)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:612)
            at dalvik.system.NativeStart.main(Native Method)
     Caused by: java.lang.IllegalArgumentException: is == null
            at org.kxml2.io.KXmlParser.setInput(KXmlParser.java:1625)
            at net.osmand.router.RoutingConfiguration.parseFromInputStream(RoutingConfiguration.java:184)
            at net.osmand.router.RoutingConfiguration.getDefault(RoutingConfiguration.java:169)
            at net.osmand.plus.helpers.AvoidSpecificRoads.getBuilder(AvoidSpecificRoads.java:44)
            at net.osmand.plus.helpers.AvoidSpecificRoads.<init>(AvoidSpecificRoads.java:38)
            at net.osmand.plus.OsmandApplication.onCreate(OsmandApplication.java:165)
            at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1007)
            at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4473)
            at android.app.ActivityThread.access$1500(ActivityThread.java:144)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1265)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:136)
            at android.app.ActivityThread.main(ActivityThread.java:5146)
            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:796)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:612)
            at dalvik.system.NativeStart.main(Native Method)
02-11 10:34:58.010  26873-26880/net.osmand D/dalvikvm﹕ null clazz in OP_INSTANCE_OF, single-stepping

【问题讨论】:

  • cafebabe 是正确的魔法,但主要版本 34 是指使用 JDK 1.8 编译的类文件。 Android 工具尚不支持 Java 8。
  • 是的,这有帮助。谢谢。我将 java 更改为 1.7,构建错误已完成,但现在出现运行时错误。
  • 运行时异常是因为资源“routing.xml”没有正确嵌入(java资源,不是android资源!)。您如何包含资源?

标签: android osmdroid


【解决方案1】:

我也遇到了同样的问题,我将所有的 .java 类文件移到了根包中,所有的错误都消失了……

【讨论】:

  • 我遇到了类似的问题,将 .jar 文件移动到项目的根目录,错误也消失了。我希望我明白为什么
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2013-06-30
  • 2014-08-12
  • 2015-08-13
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多