Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android to Unable to instantiate Application java.lang.ClassNotFoundException:

Tags:

android

I am working on application which is host on android market. Sometimes (once a month ) I got a crash report:

Unable to instantiate application java.lang.ClassNotFoundException

App downloads are between 10,000-50,000. I don't know why this exceptions raise on some devices not all ( I tested it on 3 different devices & I couldn't re-produce it at my end).

I read articles/suggestions on different android forums regarding the issue but I didn't succeed in solving it. Does anyone face similar issue & suggest me what should I do?

Note: I am extending application class like this

public class MyApplication extends Application {  } 

I register it in the manifest.xml like this

<application android:icon="@drawable/app_icon"     android:label="@string/my_app_name" android:name="MyApplication"> 

Stack Trace :

java.lang.RuntimeException: Unable to instantiate application  com.xyz.MyApplication      java.lang.ClassNotFoundException: com.xyz.MyApplication in loader dalvik.system.PathClassLoader[/mnt/asec/com.xyz-1/pkg.apk] at android.app.ActivityThread$PackageInfo.makeApplication(ActivityThread.java:650) at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4238) at android.app.ActivityThread.access$3000(ActivityThread.java:126) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2076) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:123) at android.app.ActivityThread.main(ActivityThread.java:4633) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:521) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) at dalvik.system.NativeStart.main(Native Method) Caused by: java.lang.ClassNotFoundException: com.xyz.MyApplication in loader dalvik.system.PathClassLoader[/mnt/asec/com.xyz-1/pkg.apk] at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243) at java.lang.ClassLoader.loadClass(ClassLoader.java:573) at java.lang.ClassLoader.loadClass(ClassLoader.java:532) at android.app.Instrumentation.newApplication(Instrumentation.java:942) at android.app.ActivityThread$PackageInfo.makeApplication(ActivityThread.java:645) 

I don't know why application crash on some devices not all.

like image 974
Mudassar Avatar asked Apr 25 '12 07:04

Mudassar


1 Answers

Some other similar questions indicate that this can be a user error. "/mnt/asec/..." indicates that the app is running from the sdcard. If the sdcard is removed it could cause this error. 3rd party apps or rooted devices can probably move an app to the sdcard even if its not allowed by the manifest.

Similar Question

like image 73
paul Avatar answered Sep 28 '22 01:09

paul