在某些设备上 运行 一个 android 应用程序时出现奇怪的 RuntimeException

Strange RuntimeException when running an android app on some devices

我最近制作了一个Android应用程序并将调试版本发布给一些人进行测试。一切似乎都很好,除了少数设备,该应用程序无法 运行。经调查,打开应用程序时出现以下异常:

E/AndroidRuntime: FATAL EXCEPTION: main
Process: ir.irancell.neshan, PID: 23340
java.lang.RuntimeException: Unable to instantiate application com.android.tools.fd.runtime.BootstrapApplication: java.lang.ClassNotFoundException: Didn't find class "com.android.tools.fd.runtime.BootstrapApplication" on path: DexPathList[[zip file "/data/app/ir.irancell.neshan-1.apk"],nativeLibraryDirectories=[/data/app-lib/ir.irancell.neshan-1, /vendor/lib, /system/lib]]
    at android.app.LoadedApk.makeApplication(LoadedApk.java:516)
    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4722)
    at android.app.ActivityThread.access00(ActivityThread.java:172)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1368)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:146)
    at android.app.ActivityThread.main(ActivityThread.java:5653)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:515)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1291)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1107)
    at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.android.tools.fd.runtime.BootstrapApplication" on path: DexPathList[[zip file "/data/app/ir.irancell.neshan-1.apk"],nativeLibraryDirectories=[/data/app-lib/ir.irancell.neshan-1, /vendor/lib, /system/lib]]
    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:67)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
    at android.app.Instrumentation.newApplication(Instrumentation.java:981)
    at android.app.LoadedApk.makeApplication(LoadedApk.java:511)
    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4722) 
    at android.app.ActivityThread.access00(ActivityThread.java:172) 
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1368) 
    at android.os.Handler.dispatchMessage(Handler.java:102) 
    at android.os.Looper.loop(Looper.java:146) 
    at android.app.ActivityThread.main(ActivityThread.java:5653) 
    at java.lang.reflect.Method.invokeNative(Native Method) 
    at java.lang.reflect.Method.invoke(Method.java:515) 
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1291) 
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1107) 
    at dalvik.system.NativeStart.main(Native Method) 

奇怪的是,当我将那些有问题的设备连接到 Android Studio 并专门为它们编译应用程序时,应用程序 运行 就很好了。但是,如果我生成一个 APK 文件并单独安装它们,某些设备仍然存在该问题。
谷歌搜索这个问题,有人说 ( and here) 罪魁祸首是 Instant Run 功能,但我认为当您使用 Generate signed APKInstant Run 不负责任。那么可能是什么问题?

是的,看来 Instant Run 是这里的罪魁祸首。所以禁用它解决了问题。