Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 915
Skoky Avatar asked Sep 23 '10 17:09

Skoky


People also ask

What causes Java Lang ClassNotFoundException?

The java. lang. ClassNotFoundException is thrown when the Java Virtual Machine (JVM) tries to load a particular class and the specified class cannot be found in the classpath. The Java ClassNotFoundException is a checked exception and thus, must be declared in a method or constructor's throws clause.

What is Java Lang ClassNotFoundException?

ClassNotFoundException is a checked exception and occurs when the Java Virtual Machine (JVM) tries to load a particular class and the specified class cannot be found in the classpath. In older days, there are no editors like Eclipse are available.


1 Answers

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" > 
like image 197
phreakhead Avatar answered Oct 14 '22 16:10

phreakhead