Android Studio: ClassNotFoundException

后端 未结 17 890
时光说笑
时光说笑 2021-01-11 13:23

i was busy with my app for over a week, when suddenly:

11-12 07:59:17.860    1653-1653/nl.test.myapp E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.lang.Runtim         


        
相关标签:
17条回答
  • 2021-01-11 13:53

    Your MainActivity.java is excluded from compile, so this class isn't included in .apk. Remove line:

    <file url="file://$PROJECT_DIR$/src/nl/test/MyApp.java" />
    

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

    Source

    0 讨论(0)
  • 2021-01-11 13:55

    If you're creating an android library, you may simply have forgotten to import your library in your app build.gradle with the implementation project keyword :

    dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) testImplementation 'junit:junit:4.12' implementation 'com.android.support:design:27.0.2' implementation 'com.android.support:mediarouter-v7:27.0.2' implementation project(':mylib-module:mymodule') implementation 'com.google.firebase:firebase-core:10.0.1' }

    Hope this helps :)

    0 讨论(0)
  • 2021-01-11 13:58

    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.

    0 讨论(0)
  • 2021-01-11 13:58

    This happened to me too, and none of the postings here helped. My problem was also caused by my having renamed the root package. My ClassNotFoundException was showing a DexPathList which was the old path to my package. I found the cause was in my Gradle Script called "build.gradle (Module: app)" I had a line saying: applicationId "old package name". I changed this to the new package name, did a gradle sync, and everything worked.

    0 讨论(0)
  • 2021-01-11 14:00

    I ran into this. My app had been running fine and one day it just started running into these ClassNotFoundExceptions. My code hadn't changed at all.

    As far as I can tell, it ended up being a bug in the build of Android Studio. I had recently updated to the latest release on the canary channel.

    Switching back to an older release on the dev channel got things working again:

    1. Go into Settings / Appearance & Behavior / System Settings / Update
    2. Change to Dev Channel and Check Now.
    0 讨论(0)
  • 2021-01-11 14:00

    As i can see in your Log ,

    nativeLibraryDirectories=[/data/app-lib/nl.test.myapp-2, /system/lib

    For that you can change your lib to libs , I did this and it resolved my problem.

    you would see some error mark on project to resolve that go to project properties and java build path, Remove all the libraries from there . You will not see this error again. :)

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