This often happens to me when I export a signed apk from Eclipse. I haven't got to the root of the issue but my work-around is simply to re-export the apk and try installing on to a device for testing. I would estimate about 3/4 of the time the apk is fine and the rest of the time it crashes immediately upon trying to open the app.
Application crashes with error on maps.jar file when install from exported apk and works if i installed it from eclipse
-
29-11-2021 - |
Question
my application uses google maps api. It works well if i installed it from eclipse but when i export apk and install from that apk the application crashes and report this error
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>
Can any one help ?
Solution
OTHER TIPS
I can't observer what @David Currie describes. For me, exporting or compiling through exclipse work in the same manner, if one works, the other one works too.
When you look at the stack trace, it mentions two files that should be in the class loader :
- /system/framework/com.google.android.maps.jar
- /mnt/aseccom.mycom.myapp-1/pkg.apk
do those files exist ? What is the extension of the second one ? Its name is strange. It ends with "-1.pkg.apk". You should investigate this first. Also you can use the tool dexdump to check if your class com.mycom.myapp.MainActivity
is inside your apk file.
Double check if you get a line containing "class descriptor" for com.mycom.myapp.MainActivity
in your dex file inside your release apk.