java.lang.ClassNotFoundException on working app

I have created and published my first Android app. It's very simple. It works fine on simulator and some phones, but I am getting this error:

java.lang.RuntimeException: Unable to instantiate application cz.teamnovak.droid.Novak ESC Track guide: java.lang.ClassNotFoundException: cz.teamnovak.droid.Novak ESC Track guide in loader dalvik.system.PathClassLoader[/data/app/cz.teamnovak.droid-1.apk]
    at android.app.ActivityThread$PackageInfo.makeApplication(ActivityThread.java:649)
    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4232)
    at android.app.ActivityThread.access$3000(ActivityThread.java:125)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2071)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:123)
    at android.app.ActivityThread.main(ActivityThread.java:4627)
    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: cz.teamnovak.droid.Novak ESC Track guide in loader dalvik.system.PathClassLoader[/data/app/cz.teamnovak.droid-1.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:644)
    ... 11 more

Any idea what can cause this?


Yep, I had this exact same problem. It was because I specified the android:name attribute in the application node in the manifest file.

Your Android Manifest file probably looks something like this:

   <application 
       android:name="Novak ESC Track guide" 
       android:icon="@drawable/icon" 
       android:label="@string/app_name" 
       android:description="@string/help_text" >

Do not use the android:name attribute! unless you've implemented a custom Application object.

The application:name attribute has nothing to do with the name of your app. This is the name of a specific class to load as your Application instance. That's why you would get the ClassNotFoundException if that class wouldn't exist.

For the name of the app use the android:label attribute on this same application node instead.

Remove it and it should work:

<application 
    android:icon="@drawable/icon" 
    android:label="@string/app_name" 
    android:description="@string/help_text" >

Something like this happened when I changed the build target to 3.2. After digging around I found that a had named the jar lib folder "lib" instead of "libs". I just renamed it to libs and updated the references on the Java build path and everything was working again. Maybe this will help someone...