我的应用程序在仿真器中甚至在由android studio安装用于调试目的的真实设备中都运行良好,但是如果使用apk文件手动安装,则会崩溃。
我已经准备好粘贴其他任何代码,如需要的话,可以输入“活动”。
这是logcat:
04-14 12:20:44.392 6220-6220/? I/art: Late-enabling -Xcheck:jni 04-14 12:20:44.465 6220-6220/test.planner W/System: ClassLoader referenced unknown path: /data/app/test.planner-1/lib/arm 04-14 12:20:44.467 6220-6220/test.planner I/InstantRun: starting instant run server: is main process 04-14 12:20:44.470 6220-6220/test.planner D/AndroidRuntime: Shutting down VM 04-14 12:20:44.471 6220-6220/test.planner E/AndroidRuntime: FATAL EXCEPTION: main Process: test.planner, PID: 6220 java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{test.planner/test.planner.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "test.planner.MainActivity" on path: DexPathList[[zip file "/data/app/test.planner-1/base.apk"],nativeLibraryDirectories=[/data/app/test.planner-1/lib/arm, /vendor/lib, /system/lib]] at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2327) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) at android.app.ActivityThread.-wrap11(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:148) at android.app.ActivityThread.main(ActivityThread.java:5417) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) Caused by: java.lang.ClassNotFoundException: Didn't find class "test.planner.MainActivity" on path: DexPathList[[zip file "/data/app/test.planner-1/base.apk"],nativeLibraryDirectories=[/data/app/test.planner-1/lib/arm, /vendor/lib, /system/lib]] 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 android.app.Instrumentation.newActivity(Instrumentation.java:1067) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2317) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) at android.app.ActivityThread.-wrap11(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:148) at android.app.ActivityThread.main(ActivityThread.java:5417) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) Suppressed: java.lang.ClassNotFoundException: test.planner.MainActivity 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) ... 12 more Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available
只需转到:
Android Studio --> File --> Setting --> Build, execution, deploy --> Instant run.
并禁用instant run。
instant run