2

I recently released my app to the market and my app is crashing when loaded for a few users. I cannot reproduce the error on my phone or on my emulator. Here is the stack..

Any reason the app is crashing for a few people? Has anyone experienced this problem?

java.lang.RuntimeException: Unable to instantiate application
xyz.android.MyApplication: java.lang.ClassNotFoundException: xyz.android.MyApplication in loader dalvik.system.PathClassLoader[/data/app/rageup.android.official-2.apk]
at android.app.ActivityThread$PackageInfo.makeApplication(ActivityThread.java:671)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4322)
at android.app.ActivityThread.access$3200(ActivityThread.java:129)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2155)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:143)
at android.app.ActivityThread.main(ActivityThread.java:4717)
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:868)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: xyz.android.MyApplication in loader     dalvik.system.PathClassLoader[/data/app/xyz.android.official-2.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:666)
... 11 more

Here is a snippet of my Manifest file

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="xyz.android.official"
android:versionCode="AAA"
android:versionName="AAA" >

<uses-sdk android:minSdkVersion="7" />
<application
    android:name="xyz.android.MyApplication"
    android:icon="@drawable/myicon"
    android:label="@string/app_name">

Here is my the MyApplication class.

public class MyApplication extends Application 
{ 

public int someVar = 555;
private static MyApplication me;

@Override
public void onCreate() {        
    super.onCreate();
    me = this ;
}

public void setSomeVar(int someVar)
{       
    this.someVar = someVar;
}

public int getSomeVar()
{
    return someVar;
}

public static MyApplication getInstance() {
     return me;
}

}
Bill the Lizard
  • 398,270
  • 210
  • 566
  • 880
James Fazio
  • 6,370
  • 9
  • 38
  • 47

1 Answers1

0

This mostly caused changed of target build. Some says you need to change library folder to lib from libs, other says you should write .MyApplication in Manifest.xml.

source : java.lang.ClassNotFoundException on working app

Community
  • 1
  • 1
HelmiB
  • 12,303
  • 5
  • 41
  • 68
  • This looks like it could do the trick, but I don't seem to even have a lib folder. – James Fazio Sep 24 '12 at 03:10
  • your manifest.xml ` ` – HelmiB Sep 24 '12 at 03:37
  • Both of those changes crash the app on the emulator. – James Fazio Sep 24 '12 at 03:40
  • I see some suggestions here, but I do not have a "lib" folder in my project – James Fazio Sep 24 '12 at 04:09
  • This also sometimes happens randomly with exported apps. I haven't found a solution yet, but re-exporting it a couple of times seems to work. I suspect proguard is doing weird stuff. –  Feb 16 '13 at 19:15
  • It depends on where **MyApplication** is created. If it's in the top level package, then declaring it as `.MyApplication` will suffice. If it's in a sub-package, then it should be declared as `..MyApplication`, where **** is the actual name of the package. – ChuongPham Nov 27 '13 at 13:20