3

For my Android application, I get the following error in Google Play's developer console:

java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{PACKAGE_NAME/PACKAGE_NAME.MainActivity}: java.lang.ClassNotFoundException: PACKAGE_NAME.MainActivity in loader dalvik.system.PathClassLoader[/mnt/asec/PACKAGE_NAME-1/pkg.apk]
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1573)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667)
at android.app.ActivityThread.access$1500(ActivityThread.java:117)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3693)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:907)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:665)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: PACKAGE_NAME.MainActivity in loader dalvik.system.PathClassLoader[/mnt/asec/PACKAGE_NAME-1/pkg.apk]
at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1565)

Although this error appears extremely rarely (and can probably be neglected), I find it cleaner to have a error-free developer console :) And furthermore, I would just like to know the causes for this error.

Yes, it seems as if there was a class that could not be found. But why? How can I prevent this?

caw
  • 30,999
  • 61
  • 181
  • 291

1 Answers1

2

Update(4/26/15):

After further research I believe you are right in the fact that its definitely a user error. The [/mnt/asec/PACKAGE_NAME-1/pkg.apk] most likely means they are trying to move your app to the SD card. Please read here:

Android intermittent class not found run time exception

"Unable to instantiate activity" error

Android: Unable to instantiate activity / ClassNotFoundException

Original:

This is a Java RuntimeException as seen by Logcat. I've seen this happen many times before when I have not added the Activity to manifest correctly.

java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{PACKAGE_NAME/PACKAGE_NAME.MainActivity}: java.lang.ClassNotFoundException: PACKAGE_NAME.MainActivity in loader dalvik.system.PathClassLoader[/mnt/asec/PACKAGE_NAME-1/pkg.apk]
Community
  • 1
  • 1
Jared Burrows
  • 54,294
  • 25
  • 151
  • 185
  • Thank you! My manifest is okay, of course. This is why I wrote that the bug occurs extremely seldom. `` Can this be the user's device's fault as it probably doesn't load the manifest correctly or so? – caw Jun 20 '12 at 09:06
  • I believe you are right in the fact this is a user error, please read my updated response :) – Jared Burrows Jun 20 '12 at 13:09
  • Thank you very much :) So they are probably using a third-party app to move my app to the SD card although they shouldn't? – caw Jun 20 '12 at 14:32
  • I am guessing so. If the default(natural) way of moving the app to the sd card is not available, technically they should not do it, so it must be a 3rd party application. – Jared Burrows Jun 20 '12 at 14:47