我的应用程序使用google maps api。如果我从eclipse安装它,但是当我导出apk并从该apk安装应用程序崩溃并报告此错误时,它运行良好
11-15 16:30:29.692: E/AndroidRuntime(14405): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.mycom.myapp/com.mycom.myapp.MainActivity}: java.lang.ClassNotFoundException: com.mycom.myapp.MainActivity in loader dalvik.system.PathClassLoader[/system/framework/com.google.android.maps.jar:/mnt/aseccom.mycom.myapp-1/pkg.apk]
11-16 01:47:41.999: E/AndroidRuntime(19577): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1785)
11-16 01:47:41.999: E/AndroidRuntime(19577): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1893)
11-16 01:47:41.999: E/AndroidRuntime(19577): at android.app.ActivityThread.access$1500(ActivityThread.java:135)
11-16 01:47:41.999: E/AndroidRuntime(19577): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1054)
11-16 01:47:41.999: E/AndroidRuntime(19577): at android.os.Handler.dispatchMessage(Handler.java:99)
11-16 01:47:41.999: E/AndroidRuntime(19577): at android.os.Looper.loop(Looper.java:150)
11-16 01:47:41.999: E/AndroidRuntime(19577): at android.app.ActivityThread.main(ActivityThread.java:4389)
11-16 01:47:41.999: E/AndroidRuntime(19577): at java.lang.reflect.Method.invokeNative(Native Method)
11-16 01:47:41.999: E/AndroidRuntime(19577): at java.lang.reflect.Method.invoke(Method.java:507)
11-16 01:47:41.999: E/AndroidRuntime(19577): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:849)
11-16 01:47:41.999: E/AndroidRuntime(19577): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:607)
11-16 01:47:41.999: E/AndroidRuntime(19577): at dalvik.system.NativeStart.main(Native Method)
11-16 01:47:41.999: E/AndroidRuntime(19577): Caused by: java.lang.ClassNotFoundException: com.mycom.myapp.MainActivity in loader dalvik.system.PathClassLoader[/system/framework/com.google.android.maps.jar:/mnt/asec/com.mycom.myapp-1/pkg.apk]
11-16 01:47:41.999: E/AndroidRuntime(19577): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
11-16 01:47:41.999: E/AndroidRuntime(19577): at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
11-16 01:47:41.999: E/AndroidRuntime(19577): at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
11-16 01:47:41.999: E/AndroidRuntime(19577): at android.app.Instrumentation.newActivity(Instrumentation.java:1040)
11-16 01:47:41.999: E/AndroidRuntime(19577): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1777)
11-16 01:47:42.009: E/EmbeddedLogger(183): App crashed! Process: com.mycom.myapp
11-16 01:47:42.009: E/EmbeddedLogger(183): App crashed! Package: com.mycom.myapp v1 (1.0)
11-16 01:47:42.009: E/EmbeddedLogger(183): Error getting package label: com.mycom.myapp
11-16 01:47:42.009: E/EmbeddedLogger(183): java.lang.NullPointerException
11-16 01:47:42.009: E/EmbeddedLogger(183): at com.htc.server.embedded.EmbeddedLogger.onHandleApplicationCrash(EmbeddedLogger.java:59)
11-16 01:47:42.009: E/EmbeddedLogger(183): at com.android.server.am.ActivityManagerService.handleApplicationCrash(ActivityManagerService.java:7739)
11-16 01:47:42.009: E/EmbeddedLogger(183): at android.app.ActivityManagerNative.onTransact(ActivityManagerNative.java:1033)
11-16 01:47:42.009: E/EmbeddedLogger(183): at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:1657)
11-16 01:47:42.009: E/EmbeddedLogger(183): at android.os.Binder.execTransact(Binder.java:320)
11-16 01:47:42.009: E/EmbeddedLogger(183): at dalvik.system.NativeStart.run(Native Method)
11-16 01:47:42.009: E/EmbeddedLogger(183): Application Label: <ERROR>
任何人都可以帮忙吗?
答案 0 :(得分:1)
当我从Eclipse导出签名的apk时,这经常发生在我身上。我没有找到问题的根源,但我的解决方法只是重新导出apk并尝试安装到设备进行测试。我估计大约3/4的时候apk很好,剩下的时间它会在尝试打开应用程序时立即崩溃。
答案 1 :(得分:1)
我无法观察@David Currie描述的内容。对我来说,通过exclipse工作以相同的方式导出或编译,如果有人工作,另一个也可以工作。
当你查看堆栈跟踪时,它会提到应该在类加载器中的两个文件:
这些文件存在吗?第二个的扩展是什么?它的名字很奇怪。它以“-1.pkg.apk”结尾。你应该先调查一下。您还可以使用工具dexdump检查您的班级com.mycom.myapp.MainActivity
是否在您的apk文件中。
仔细检查你的发布apk中你的dex文件中是否有com.mycom.myapp.MainActivity
的“类描述符”行。