Java.lang.RuntimeException: Unable to instantiate Activity ComponentInfo / java.lang.ClassNotFoundException

I had this error while working on my device. I looked through this problem and I am sure that I do not have the same problems as mentioned. Both of my actions are declared in AndroidManifest, and an intent filter exists. I have no libraries at all (except for the v4 support library, but declaring it does not change the problem). I tried replacing carpedujourproductions.quickpronote.MainActivity with .MainActivity in the manifest, but still no luck. I am running Android Studio 0.2.5, so I could not find how to solve potential problems related to Java Build Path / Order and Export

I couldn't help but notice that my MainActivity icon in the tree had a gray cross in the upper left corner.

Logcat:

 E/AndroidRuntime: FATAL EXCEPTION: main java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{carpedujourproductions.quickpronote/carpedujourproductions.quickpronote.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "carpedujourproductions.quickpronote.MainActivity" on path: DexPathList[[zip file "/data/app/carpedujourproductions.quickpronote-2.apk"],nativeLibraryDirectories=[/data/app-lib/carpedujourproductions.quickpronote-2, /vendor/lib, /system/lib]] at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2157) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2281) at android.app.ActivityThread.access$600(ActivityThread.java:148) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1263) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:137) at android.app.ActivityThread.main(ActivityThread.java:5124) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:525) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553) at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:110) at dalvik.system.NativeStart.main(Native Method) Caused by: java.lang.ClassNotFoundException: Didn't find class "carpedujourproductions.quickpronote.MainActivity" on path: DexPathList[[zip file "/data/app/carpedujourproductions.quickpronote-2.apk"],nativeLibraryDirectories=[/data/app-lib/carpedujourproductions.quickpronote-2, /vendor/lib, /system/lib]] at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:53) at java.lang.ClassLoader.loadClass(ClassLoader.java:501) at java.lang.ClassLoader.loadClass(ClassLoader.java:461) at android.app.Instrumentation.newActivity(Instrumentation.java:1061) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2148) ... 12 more 

Feel free to browse the code here for AndroidManifest, MainActivity.java, FirstRun.java, etc.

+6
android
Aug 30 '13 at 12:34
source share
6 answers

Your MainActivity.java excluded from compilation, so this class is not included in .apk. Delete line:

 <file url="file://$PROJECT_DIR$/src/carpedujourproductions/quickpronote/MainActivity.java" /> 

from the excludeFromCompile section of the .idea/compiler.xml file (or you can do this from the IDE settings).

+3
Aug 30 '13 at 12:41
source share

This error can be raised for several reasons, as my experience I reveal two of them.

  • if we have some lines of code in the resource files that are inserted by the SVN client, such as smartSVN or the tortoise.

     <<<<<<< .mine <string name="pathConfiguration">http://jorgesys/app/config_development.xml</string> ======= >>>>>>> .r124 

    <<<<<<<.mine

    delete these characters:

     <string name="pathConfiguration">http://jorgesys/app/config_development.xml</string> 
  • Add the line to the .classpath file

     <classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/> 

that's an example:

  <?xml version="1.0" encoding="UTF-8"?> <classpath> <classpathentry kind="src" path="src"/> <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/> <classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/> <classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/> <classpathentry kind="src" path="gen"/> <classpathentry kind="output" path="bin/classes"/> </classpath> 

Now it works! =)

he will fix the exception

+2
Jan 30 '14 at 18:24
source share

I had the same problem. Project cleanup should do the trick

+2
Apr 05 '14 at 23:40
source share

If you add additional libraries to your project, you need to export them with your project if some classes are excluded.

right-click your project and open Properties. Click Java Build Path in the left pane and go to the Order and Export tab. You may need to check out third-party libraries to add them to create the path and export them to apk. Also note that the order of libs is also important, and the top ones are the higher properties that they have when building apk.

+1
Sep 05 '14 at 9:20
source share

I just changed

 compileOptions{ sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } 

to

 compileOptions{ sourceCompatibility JavaVersion.VERSION_1_7 targetCompatibility JavaVersion.VERSION_1_7 } 

and it worked like a charm .....

+1
Sep 05 '14 at 10:59
source share

This worked for me: Add this to your APLICATION class.

 @Override protected void attachBaseContext(Context base) { super.attachBaseContext(base); MultiDex.install(getBaseContext()); } 
0
Feb 22 '18 at 14:11
source share



All Articles