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
android:name=".MyApplication"
also consider adding full package
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
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,
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.