java.lang.ClassNotFoundException: Didn't find class "XXX.MainActivity" on path: DexPathList[...

java.lang.ClassNotFoundException: Didn't find class

10-19 10:19:27.194 31597-31597/com.t.testdemo.myapplication E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.t.testdemo.myapplication, PID: 31597
    java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.t.testdemo.myapplication/com.t.testdemo.myapplication.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "com.t.testdemo.myapplication.MainActivity" on path: DexPathList[[zip file "/data/app/com.t.testdemo.myapplication-2YZBPHmPugJdFOpwEIAbyw==/base.apk"],nativeLibraryDirectories=[/data/app/com.t.testdemo.myapplication-2YZBPHmPugJdFOpwEIAbyw==/lib/arm64, /system/lib64, /vendor/lib64]]
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2901)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3078)
        at android.app.ActivityThread.-wrap11(Unknown Source:0)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1794)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:183)
        at android.app.ActivityThread.main(ActivityThread.java:7014)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:514)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:888)
     Caused by: java.lang.ClassNotFoundException: Didn't find class "com.t.testdemo.myapplication.MainActivity" on path: DexPathList[[zip file "/data/app/com.t.testdemo.myapplication-2YZBPHmPugJdFOpwEIAbyw==/base.apk"],nativeLibraryDirectories=[/data/app/com.t.testdemo.myapplication-2YZBPHmPugJdFOpwEIAbyw==/lib/arm64, /system/lib64, /vendor/lib64]]
        at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:125)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
        at android.app.Instrumentation.newActivity(Instrumentation.java:1174)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2891)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3078) 
        at android.app.ActivityThread.-wrap11(Unknown Source:0) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1794) 
        at android.os.Handler.dispatchMessage(Handler.java:106) 
        at android.os.Looper.loop(Looper.java:183) 
        at android.app.ActivityThread.main(ActivityThread.java:7014) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:514) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:888) 

开发工具 Android Studio 3.1.4
测试机 oppo R15
Gradle 4.4
Android Pulgin Version 3.1.4
compileSdkVersion 28

File ->New Project,然后一路next。然后Run(Shift+F10)一下:

现象就是安装Apk后不起来,点击闪退;卸载重试,继续崩溃;clean后闪退依旧;改compileSdkVersion为26,也没卵用;Invalidate and Restart,再试最后一把,继续闪退。

我也要崩溃了,默哀20秒,换个的小米手机试试吧,艾玛,竟然可以运行,说明项目没问题。垃圾手机误国啊!该死的oppo R15。

奈何最近冤假错案太多了。为了不冤枉oppo,决定换台同事电脑试试,我去,同一套代码,在同事电脑运行到oppo R15上竟不崩溃。就像从来没有崩溃过一样,岁月静好。

莫非是我的电脑和oppo R15手机八字不合?

谷歌一把:

java.lang.ClassNotFoundException: Didn't find class

把上面对勾去掉,Apply OK一下,再运行,果然不会崩溃了。

结论:

OPPO R15 不支持Instant Run。

你可能感兴趣的:(Android)