java.lang.RuntimeException: Unable to instantiate activity ComponentInfo / java.lang.ClassNotFoundException

后端 未结 5 893
别那么骄傲
别那么骄傲 2020-12-06 19:07

I\'m having this error while running on my device. I\'ve been browsing the issue and I\'m pretty sure I\'m not having the same issues as mentioned. Both of my activities are

相关标签:
5条回答
  • 2020-12-06 19:22

    If you add additional libs to your project you need to export them with your project in case that some classes excluded.

    right click your project and go to Properties. Click Java Build Path on left panel and navigate to Order and Export tab. You may need to check the third party libs in order to add them to build path and export them to apk. Also notice that the order of libs are also important, the topper they are the higher properties they have when building apk.

    0 讨论(0)
  • 2020-12-06 19:22

    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.....

    0 讨论(0)
  • 2020-12-06 19:32

    Your MainActivity.java is excluded from compile, so this class isn't included in .apk. Remove 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 IDE settings).

    0 讨论(0)
  • 2020-12-06 19:33

    I had the same problem. Cleaning the project should do the trick

    0 讨论(0)
  • 2020-12-06 19:45

    This error could be raised with several causes, for my experience i expose two of them.

    • if we have some code lines in resource files that are inserted by SVN Client like smartSVN or tortoise.

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

      <<<<<<< .mine

      removing that characters:

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

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

    this is 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! =)

    it will fix the exception

    0 讨论(0)
提交回复
热议问题