Unable to instantiate application Caused by: java.lang.ClassNotFoundException: Didn't find class on path: DexPathList

有些话、适合烂在心里 提交于 2019-12-10 11:06:45

问题


Today I fall into a strange problem, my app suddenly stop working on my USB plugged device. However it could run fine on other real devices and simulator devices.

The error dialog on screen is as usual: Unfortunately "your app name" has stopped.

To get the error messages, I run my app in debug mode and see this:

FATAL EXCEPTION: main
              Process: com.yourapp.packagename, PID: 20036
              java.lang.RuntimeException: Unable to instantiate application com.android.tools.fd.runtime.BootstrapApplication: java.lang.IllegalStateException: java.lang.ClassNotFoundException: android.support.multidex.MultiDexApplication
                  at android.app.LoadedApk.makeApplication(LoadedApk.java:676)
                  at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6294)
                  at android.app.ActivityThread.access$1800(ActivityThread.java:222)
                  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1861)
                  at android.os.Handler.dispatchMessage(Handler.java:102)
                  at android.os.Looper.loop(Looper.java:158)
                  at android.app.ActivityThread.main(ActivityThread.java:7229)
                  at java.lang.reflect.Method.invoke(Native Method)
                  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
                  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
               Caused by: java.lang.IllegalStateException: java.lang.ClassNotFoundException: android.support.multidex.MultiDexApplication
                  at com.android.tools.fd.runtime.BootstrapApplication.createRealApplication(BootstrapApplication.java:220)
                  at com.android.tools.fd.runtime.BootstrapApplication.attachBaseContext(BootstrapApplication.java:239)
                  at android.app.Application.attach(Application.java:211)
                  at android.app.Instrumentation.newApplication(Instrumentation.java:1020)
                  at android.app.Instrumentation.newApplication(Instrumentation.java:1004)
                  at android.app.LoadedApk.makeApplication(LoadedApk.java:666)
                  at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6294) 
                  at android.app.ActivityThread.access$1800(ActivityThread.java:222) 
                  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1861) 
                  at android.os.Handler.dispatchMessage(Handler.java:102) 
                  at android.os.Looper.loop(Looper.java:158) 
                  at android.app.ActivityThread.main(ActivityThread.java:7229) 
                  at java.lang.reflect.Method.invoke(Native Method) 
                  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230) 
                  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120) 
               Caused by: java.lang.ClassNotFoundException: android.support.multidex.MultiDexApplication
                  at java.lang.Class.classForName(Native Method)
                  at java.lang.Class.forName(Class.java:324)
                  at java.lang.Class.forName(Class.java:285)
                  at com.android.tools.fd.runtime.BootstrapApplication.createRealApplication(BootstrapApplication.java:209)
                  at com.android.tools.fd.runtime.BootstrapApplication.attachBaseContext(BootstrapApplication.java:239) 
                  at android.app.Application.attach(Application.java:211) 
                  at android.app.Instrumentation.newApplication(Instrumentation.java:1020) 
                  at android.app.Instrumentation.newApplication(Instrumentation.java:1004) 
                  at android.app.LoadedApk.makeApplication(LoadedApk.java:666) 
                  at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6294) 
                  at android.app.ActivityThread.access$1800(ActivityThread.java:222) 
                  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1861) 
                  at android.os.Handler.dispatchMessage(Handler.java:102) 
                  at android.os.Looper.loop(Looper.java:158) 
                  at android.app.ActivityThread.main(ActivityThread.java:7229) 
                  at java.lang.reflect.Method.invoke(Native Method) 
                  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230) 
                  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120) 
               Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.multidex.MultiDexApplication" on path: DexPathList[[zip file "/data/app/com.yourapp.packagename-1/base.apk"],nativeLibraryDirectories=[/data/app/com.yourapp.packagename-1/lib/arm64, /vendor/lib64, /system/lib64]]
                  at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
                  at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
                  at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
                  at java.lang.Class.classForName(Native Method) 
                  at java.lang.Class.forName(Class.java:324) 
                  at java.lang.Class.forName(Class.java:285) 
                  at com.android.tools.fd.runtime.BootstrapApplication.createRealApplication(BootstrapApplication.java:209) 
                  at com.android.tools.fd.runtime.BootstrapApplication.attachBaseContext(BootstrapApplication.java:239) 
                  at android.app.Application.attach(Application.java:211) 
                  at android.app.Instrumentation.newApplication(Instrumentation.java:1020) 
                  at android.app.Instrumentation.newApplication(Instrumentation.java:1004) 
                  at android.app.LoadedApk.makeApplication(LoadedApk.java:666) 
                  at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6294) 
                  at android.app.ActivityThread.access$1800(ActivityThread.java:222) 
                  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1861) 
                  at android.os.Handler.dispatchMessage(Handler.java:102) 
                  at android.os.Looper.loop(Looper.java:158) 
                  at android.app.ActivityThread.main(ActivityThread.java:7229) 
                  at java.lang.reflect.Method.invoke(Native Method) 
                  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230) 
                  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120) 
                Suppressed: java.lang.ClassNotFoundException: android.support.multidex.MultiDexApplication
                  at java.lang.Class.classForName(Native Method)
                  at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
                  at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
                  at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
                        ... 19 more
               Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available

Clear and rebuild does not work. Uninstall and reinstall app does not work. Restart Android Studio still does not work.


回答1:


After an hour struggling with this bug, I fix that by disable Instant Run and my app run fine again.



来源:https://stackoverflow.com/questions/39871338/unable-to-instantiate-application-caused-by-java-lang-classnotfoundexception-d

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!