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

前端 未结 4 2127
梦毁少年i
梦毁少年i 2021-01-30 17:29

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.C

相关标签:
4条回答
  • 2021-01-30 18:01
     android:name=".MyApplication"
    

    also consider adding full package

    0 讨论(0)
  • 2021-01-30 18:02

    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

    0 讨论(0)
  • 2021-01-30 18:05

    I think the problem is with getApplication() which I have used in 10 different place. So I have used singleton pattern to solve this.

    public class MyApplication extends Application {
        private static MyApplication me;
    
        @Override
        public void onCreate() {        
            super.onCreate();
            me = this ;
    
        }
        public static MyApplication getInstance() {
             return me;
        }
    }
    

    Now I have used getApplication() like this

         MyApplication application = MyApplication.getInstance();
    

    insted of

         MyApplication application = (MyApplication) getApplication();
    

    I have uploaded the fixed version on the market & now waiting if there is anymore this kind of crash. If everything goes perfect ( if no more crash in 2 weeks) then I will close the question. In meanwhile anyone has better idea or know the solution , please share it.
    Thanks,

    0 讨论(0)
  • 2021-01-30 18:13

    In my case, I was compiling and signing with Eclipse ADT (with File > Export > Export Android Application...) but missing some classes if I decompile my .apk. To solve it I use "Export an unsigned APK" and sign it using jarsigner and zipalign.

    0 讨论(0)
提交回复
热议问题