Background
Not so long ago, Google has changed the Google Play Console, so that crashes are automatically being reported as soon as they occur, having it as part of what they call "Android Vital".
From this day, I got many crash reports that I've decided to fix for my app.
The problem
Among some bugs I've fixed (and one that I haven't, here), there is another quite common crash, with this crash log or similar:
java.lang.RuntimeException:
at android.app.LoadedApk.makeApplication(LoadedApk.java:572)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4768)
at android.app.ActivityThread.access$1500(ActivityThread.java:176)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1498)
at android.os.Handler.dispatchMessage(Handler.java:111)
at android.os.Looper.loop(Looper.java:194)
at android.app.ActivityThread.main(ActivityThread.java:5576)
at java.lang.reflect.Method.invoke(Native Method:0)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:956)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:751)
Caused by: java.lang.ClassNotFoundException:
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.newApplication(Instrumentation.java:984)
at android.app.LoadedApk.makeApplication(LoadedApk.java:567)
This crash seem to be affecting various Android versions and devices, yet there aren't much clues about how to fix it:
What I've tried
The only thing I've found to solve such a crash, is by using multi-dex, as written here.
Seeing that even though my app is very small and barely using third party libraries (hence doesn't even get near the 64K methods count), and that multi-dex is not even needed on Android 5.x and above, I was still curious if this would help, but in just one day of trying it, it actually caused the crash to occur more frequently:
So I quickly stopped using it, and came back to without using it.
The questions
- Why does it occur?
- Is there any way to avoid this? Will avoiding extending Application class help?
- How common is it for other apps?
- Why would multi-dexing actually cause more issues with it?
- From users point of view, do users who have this issue - always have it? Does specific devices or Android versions have this issue? Does a restart of the app or re-installing of it help? What exactly is the experience the users get from this?