1

So I'm facing this issue for some time now. While debugging I'm using my device which runs Android 5.1 (L). When I'm done, I pick up the app-debug.apk from /app/build/output/apk and forward it to the testing dept via Beta (by Fabric).

So on testers side, when installed on a device running Android 4.4 (K), the app crashes when opened. This is not an issue with Fabric because the same thing happens with other channels like slack, email, etc.

If I build the app again on an emulator running Android K and send the apk, it will run fine on testers devices. Yes the app crashes on multiple devices running Android 4.4 though.

I could find nothing related to this on SO, so thought to put this up. Is this a known issue with Android Studio or am i missing something?

I'm using:

  • Android Studio V2.1.3
  • Min. SDK version 15
  • Target SDK version 23
  • Compiled SDK version 23
  • Build tools version 24.0.2

If this is not a bug, does it mean we have to generate signed apk on a lower Android version so that it will run on all devices?

Does anyone know about this issue?

Update: The build that crashes on Android K works fine on Android L and above.

Update: I was able to get the Logcat:

FATAL EXCEPTION: mainProcess: com.myapp.qa, PID: 3570 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/com.myapp.qa-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.myapp.qa-2, /vendor/lib, /system/lib]]
    at android.app.LoadedApk.makeApplication(LoadedApk.java:516)
    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4317)
    at android.app.ActivityThread.access$1500(ActivityThread.java:135)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:136)
    at android.app.ActivityThread.main(ActivityThread.java:5017)
    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:779)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
    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/com.myapp.qa-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.myapp.qa-2, /vendor/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:975)
    at android.app.LoadedApk.makeApplication(LoadedApk.java:511)
    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4317) 
    at android.app.ActivityThread.access$1500(ActivityThread.java:135) 
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256) 
    at android.os.Handler.dispatchMessage(Handler.java:102) 
    at android.os.Looper.loop(Looper.java:136) 
    at android.app.ActivityThread.main(ActivityThread.java:5017) 
    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:779) 
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595) 
    at dalvik.system.NativeStart.main(Native Method) 

UPDATE 7/12/2016: I've tried adding multi-dex support and it doesn't solve the issue. The logcat gives the same logs.

Reaz Murshed
  • 23,691
  • 13
  • 78
  • 98
Prasad Pawar
  • 1,606
  • 1
  • 15
  • 30
  • Please post your logcat. – Reaz Murshed Dec 05 '16 at 09:05
  • @ReazMurshed check my update. – Prasad Pawar Dec 05 '16 at 10:58
  • If you have minify on, kill it. Unless your app should have so many thing that it should exceed the dex limit, it should be fine. with the multi-dex thing. But, I've seen minify wrongly remove classes. In fact, the latest version of Android Studio has a @tag to prevent it's removal. – Tatarize Dec 07 '16 at 09:48

1 Answers1

5

Please check if you've instant run option enabled or not.

Go to Preferences of your Android Studio and then find the Instant Run option under Build, Execution, Deployment.

Uncheck the check boxes to disable instant run and then again clean and build the code in your device. Then pass the debug apk to the testing team. Hope it'll not crash this time.

Update

Seems like your problem is already asked and answered here. Try enabling multidex support in your build.gradle.

defaultConfig {
    ...
    minSdkVersion 14
    targetSdkVersion 21
    ...

    // Enabling multidex support.
    multiDexEnabled true
}
Community
  • 1
  • 1
Reaz Murshed
  • 23,691
  • 13
  • 78
  • 98
  • I'm using instant run for debugging. But before sending out the build for testing, i always use the option 'clean and rerun'. So instant run shouldn't be an issue. And we do need it while development; saves a lot of build time. Also, disabling a feature like this shouldn't be a solution right? – Prasad Pawar Dec 05 '16 at 08:51
  • You just need to disable it while building a debug apk for the testers. Then again you can enable it while development. – Reaz Murshed Dec 05 '16 at 08:52
  • Nope. Tried it and still an issue. – Prasad Pawar Dec 05 '16 at 08:58
  • Please get the logcat of the crash and paste it here. – Reaz Murshed Dec 05 '16 at 08:59
  • I added multi dex support (followed the android developer guide https://developer.android.com/studio/build/multidex.html) but the issue is still there. No change in crash logs. – Prasad Pawar Dec 07 '16 at 07:09