Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

java.lang.RuntimeException: Unable to instantiate application, java.lang.ClassNotFoundException:

I already asked to find out the solution of this issue, but I can't get good answer for me. So I'm trying to write a question more in detail.

The below error occurs sometimes for some users. I haven't seen it through several android phones which I have for testing, but I got this crush via Google developer console roughly once a week :(

I've tried to find out to solve this problem for a long time. Some people talk it might be due to an exteranl SD card stuff, or Singletone stuff.

Besides, in previous question, a thankful guy said that I should check 'name' attribute of Applcation tag in AndroidManifest.xml. But I already put the package name on it so I don't think it's the cause of the crush.

I've been testing about an external SD card that I installed my app to external SD card and then unmounted. But I couldn't re-produce.

And about Singletone stuff, My app doesn't use an instance of Custom Application class anywhere. So I think the Singletone stuff couldn't be the cause of this issue.

Even I do not know how to re-produce the crush, so I really need a document or public stuff about it.

I'm sure there's somebody who got this error and already know how to solve. Thus, please help me know what's wrong and how I can fix it. Have a nice day, Thanks.

Error:

    java.lang.RuntimeException: Unable to instantiate
    application com.***.***.MyApplication:
    java.lang.ClassNotFoundException: com.***.***.MyApplication at
    android.app.LoadedApk.makeApplication(LoadedApk.java:501) at
    android.app.ActivityThread.handleBindApplication(ActivityThread.java:4253)
    at android.app.ActivityThread.access$1400(ActivityThread.java:143)
    at
    android.app.ActivityThread$H.handleMessage(ActivityThread.java:1301)
    at android.os.Handler.dispatchMessage(Handler.java:99) at
    android.os.Looper.loop(Looper.java:137) at
    android.app.ActivityThread.main(ActivityThread.java:4950) at
    java.lang.reflect.Method.invokeNative(Native Method) at
    java.lang.reflect.Method.invoke(Method.java:511) at
    com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:997)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:764) at
    dalvik.system.NativeStart.main(Native Method) Caused by:
    java.lang.ClassNotFoundException: com.***.***.MyApplication at
    dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:501) at
    java.lang.ClassLoader.loadClass(ClassLoader.java:461) at
    android.app.Instrumentation.newApplication(Instrumentation.java:982)
    at android.app.LoadedApk.makeApplication(LoadedApk.java:496) ... 11
    more

MyApplication.java:

public class MyApplication extends Application {
    @Override
    public void onCreate() {
        super.onCreate();
            ...
    }

    @Override
    public void onTerminate() {
        super.onTerminate();
    }

    ...

}

AndroidManifest.xml:

...
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
...
<application
        android:name="com.***.***.MyApplication"
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
like image 992
SY Kwon Avatar asked May 19 '14 05:05

SY Kwon


2 Answers

Known bug in the Google Play store upgrade process, https://code.google.com/p/android/issues/detail?id=56296

like image 114
nmr Avatar answered Sep 20 '22 11:09

nmr


This is caused due to problems on the device which is beyond your control. Even I get similar reports in dev console, but after extensive research I have concluded that you simply cannot prevent this crash from your side by using any conventional means because it is not caused by any fault in your app but a fault on user's system. You cannot control your user's system and many crashes which are caused due to unexpected behavior of the system cannot be "fixed", not by app developers.

like image 45
A.J. Avatar answered Sep 21 '22 11:09

A.J.