刚在网上下载一个AndroidStudio,随便创建一个项目生成的Apk闪退;报以下错误:
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{listview.chenmiaohui.com.mylistviewdemo/listview.chenmiaohui.com.mylistviewdemo.ListViewActivity}: java.lang.ClassNotFoundException: Didn't find class "listview.chenmiaohui.com.mylistviewdemo.ListViewActivity" on path: DexPathList[[zip file "/data/app/listview.chenmiaohui.com.mylistviewdemo-2/base.apk"],nativeLibraryDirectories=[/data/app/listview.chenmiaohui.com.mylistviewdemo-2/lib/arm64, /system/lib64, /vendor/lib64]]
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2721)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2880)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1617)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:185)
at android.app.ActivityThread.main(ActivityThread.java:6493)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:916)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:806)
Caused by: java.lang.ClassNotFoundException: Didn't find class "listview.chenmiaohui.com.mylistviewdemo.ListViewActivity" on path: DexPathList[[zip file "/data/app/listview.chenmiaohui.com.mylistviewdemo-2/base.apk"],nativeLibraryDirectories=[/data/app/listview.chenmiaohui.com.mylistviewdemo-2/lib/arm64, /system/lib64, /vendor/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at android.app.Instrumentation.newActivity(Instrumentation.java:1079)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2711)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2880)?
at android.app.ActivityThread.-wrap12(ActivityThread.java)?
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1617)?
at android.os.Handler.dispatchMessage(Handler.java:102)?
at android.os.Looper.loop(Looper.java:185)?
at android.app.ActivityThread.main(ActivityThread.java:6493)?
at java.lang.reflect.Method.invoke(Native Method)?
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:916)?
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:806)?
大致翻译了一下,也就是运行时无法实例化。找了一大圈子都是Eclipsec处理办法,最后看了好多搜了好多试了很多种办法都无法实质性的解决问题。最后直接搜"生成apk闪退"还真找到了大神们的解决办法:
1.主要还是把Android Studio的Instant Run关闭即可!
File>settings>Build,Execution,Deployment>Instnt Run>Enable Instant Run to hot swap code点掉对勾保存