Android Studio: ClassNotFoundException

Close android studio. Navigate to the project folder. Delete all files relating to intelliJ (Android Studio) i.e

  • .idea (folder)
  • *.imi (files)

Also make sure that package name matches the package in the android manifest.xml.

Then reimport the project.

This happened to me because I renamed the root package and IntelliJ (android studio) didn't track this.


I had the same problem, turns out I screwed up with some final method. Be sure to check dalvikvm errors in logcat output before the FATAL EXCEPTION. I will give you some hints on the problem. In my case, I had a final method (isResumed) which was already defined in the base class - causing runtime crash. Wasn't complaining at compile time.

Check the logs:

E/dalvikvm( 9984): Method Lcom/your/package/ui/SomeActivity;.isResumed overrides final Landroid/app/Activity;.isResumed
W/dalvikvm( 9984): failed creating vtable
...
D/AndroidRuntime( 9962): Shutting down VM
...
E/AndroidRuntime(10065): FATAL EXCEPTION: main
E/AndroidRuntime(10065): Process: com.yourpackage.ui, PID: 10065
E/AndroidRuntime(10065): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.yourpackage.ui/com.yourpackage.ui.HomeActivity}: java.lang.ClassNotFoundException: Didn't find class "com.yourpackage.ui.HomeActivity" on path: DexPathList[[zip file "/data/app/com.yourpackage.ui-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.yourpackage.ui-2, /vendor/lib, /system/lib]]
...

I created a new project in Android studio and copied everything from the old project into the new one. Now it's working again, without any(!) modifications to the code.