Rick B Rick B - 2 months ago 69
Android Question

Android RuntimeException caused by java.lang.ClassNotFoundException

Help! I have an application on the Android store and one of my users recently reported a bug, but I am unable to find where the source of the error is. Here is the ANR report:

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 "/mnt/asec/com.applicationcomp.myapplication-1/pkg.apk"],nativeLibraryDirectories=[/mnt/asec/com.applicationcomp.myapplication-1/lib, /system/lib]]
at android.app.LoadedApk.makeApplication(LoadedApk.java:516)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4580)
at android.app.ActivityThread.access$1500(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1290)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5299)
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:932)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:748)
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 "/mnt/asec/com.applicationcomp.myapplication-1/pkg.apk"],nativeLibraryDirectories=[/mnt/asec/com.applicationcomp.myapplication-1/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
at android.app.Instrumentation.newApplication(Instrumentation.java:987)
at android.app.LoadedApk.makeApplication(LoadedApk.java:511)
... 11 more


Does anyone know that causes of these errors? This apparently is occurring as soon as the app is started up on an Android 4.4 device (I've also got another report of this happening on 4.2 as well).

*****IMPORTANT NOTE******
For some reason, this seems to only be occurring on some 4.4 devices, and unfortunately I am unable to replicate it in the Android Studio Emulator

Answer

Look at https://code.google.com/p/android/issues/detail?id=199327 - seems that you enabled Instant Run feature and it causes that problem on Android 4 as it is not supported there (though it should not crash the app that rude of course, but it's probably a bug).

Try to build the app with Instant Run disabled.

According to https://medium.com/google-developers/instant-run-how-does-it-work-294a1633367f#.bo88mglpe Instant Run injects some code (App Server) into the app, who knows what may happen on Android 4 then ))

Comments