Android Question MultiDex crash on android 4.4

panagiotisden2

Active Member
Licensed User
Longtime User
updated my app in play store and i used multidex in the updated app, the next day i have some users reporting my app cant even open and the crash report is here:
Code: Copy
java.lang.RuntimeException: Unable to instantiate application android.support.multidex.MultiDexApplication: java.lang.ClassNotFoundException: Didn't find class "android.support.multidex.MultiDexApplication" on path: DexPathList[[zip file "/data/app/com.orionapps.testkok-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.orionapps.testkok-1, /vendor/lib, /system/lib]]
    at android.app.LoadedApk.makeApplication(LoadedApk.java:516)
    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4555)
    at android.app.ActivityThread.access$1500(ActivityThread.java:151)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1402)
    at android.os.Handler.dispatchMessage(Handler.java:110)
    at android.os.Looper.loop(Looper.java:193)
    at android.app.ActivityThread.main(ActivityThread.java:5333)
    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:824)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:640)
    at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.multidex.MultiDexApplication" on path: DexPathList[[zip file "/data/app/com.orionapps.testkok-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.orionapps.testkok-1, /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)
    ... 11 more

they cant even see the app's main activity it crashes instantly.
i can confirm it works on many devices including mine without a problem and the crashes are all from android 4.4 users.
any clue here?
 
Look THIS seem that multidex work without problem with Android 5 or >
A big reason (on lower version android devices) of this issue is adding Play Services dependency. Avoid adding whole Play services gradle dependency. Instead of whole Play Services dependency, add only specific dependency which you going to use in your project (such as : location, maps, places etc.).
 
Upvote 0
yes i agree with that, it works on android 5, 6.0.1 and 7.1.1. i have tested my app in devices with android 5 and higher and it works, but the crash here is reported by android 4.4 users (the same crash and only android 4.4 devices)
 
Upvote 0
Anyway i think that this way is the best for you:

Code: Copy
#ExcludeClasses: .games, .drive, .ads, .fitness, .wearable, .measurement, .cast, .auth, .nearby
#ExcludeClasses: .tagmanager, .analytics, .wallet, .plus, .vision, .gcm......
 
Upvote 0
Anyway i think that this way is the best for you:

Code: Copy
#ExcludeClasses: .games, .drive, .ads, .fitness, .wearable, .measurement, .cast, .auth, .nearby
#ExcludeClasses: .tagmanager, .analytics, .wallet, .plus, .vision, .gcm......

thought about it, but i dont know where to find the all the classes that can be excluded.
and i am using appodeal (a lot of additional jars) so i am afraid that even if i exclude some google classes, it still wont compile without multidex
 
Upvote 0
I don't recommend you to use #ExcludeClasses. Assuming that you are using the maven repositories then it will include the correct classes anyway.

Have you tested your app on an Android 4.4 device?
So it isnt longer necessary to use #ExcludeClasses ?
 
Upvote 0
So it isnt longer necessary to use #ExcludeClasses ?
Not if all libs are using maven-references.

Additionally you dont need it because of #MultiDex: true
 
Upvote 0
I don't recommend you to use #ExcludeClasses. Assuming that you are using the maven repositories then it will include the correct classes anyway.

Have you tested your app on an Android 4.4 device?

no, i haven't i assumed it will work because multidex need android >2.3...
i dont know which libraries are using maven repositories, but i get 72994 references without multidex so i cant compile it..
indeed using excludeclasses does not change anything in this number..
any possible reason for the errors? as i said im using appodeal so i have ~9 additional jars in my app plus im using #Extends: android.support.v7.app.AppCompatActivity too.
 
Upvote 0
no, i haven't i assumed it will work because multidex need android >2.3...
i dont know which libraries are using maven repositories, but i get 72994 references without multidex so i cant compile it..
indeed using excludeclasses does not change anything in this number..
any possible reason for the errors? as i said im using appodeal so i have ~9 additional jars in my app plus im using #Extends: android.support.v7.app.AppCompatActivity too.
It is not really so.... Look THIS

When running on versions prior to Android 5.0 (API level 21), using multidex is not enough to work around the linearalloc limit (issue 78035). This limit was increased in Android 4.0 (API level 14), but that did not solve it completely. And on versions lower than Android 4.0, you might reach the linearalloc limit before reaching the DEX index limit. So if you are targeting API levels lower than 14, test thoroughly on those versions of the platform, because your app might have issues at startup or when particular groups of classes are loaded.
 
Upvote 0
OK erel, you mean a completely new project or a new compiled apk of my app with multidex false?

Edit-
Oh sorry I haven't drink any coffee yet.
Sending in a minute
 
Last edited:
Upvote 0
It looks like the MultiDex support library is missing from your APK. It should be added automatically when you set #MultiDex to true.

Please add this code to Activity_Create and run your project:
Code: Copy
Dim jo As JavaObject
jo.InitializeStatic("android.support.multidex.MultiDexApplication")

It will throw an error is the MultiDex library is missing. Assuming that it doesn't throw an error then take the new APK and upload it to Google Play.
 
Upvote 0
Back
Top