I\'m trying the new MultiDex Support on my app and so far I\'ve managed to compile my app correctly, but when running it, I get the following exception:
Very strange, I got same error message, but after I fixed some gradle lines it worked. Maybe it helps somebody:
Project build.gradle:
from:
..
dependencies {
// Android Gradle Plugin
classpath 'com.android.tools.build:gradle:3.2.1'
// Analytics
**classpath 'com.google.gms:google-services:3.0.0'**
}
..
to: ..
dependencies {
// Android Gradle Plugin
classpath 'com.android.tools.build:gradle:3.2.1'
// Analytics
**classpath 'com.google.gms:google-services:3.2.1'**
}
..
In the module build.gradle:
from:
..
dependencies {
implementation 'com.android.support:multidex:1.0.3'
implementation 'com.android.support:support-v4:26.1.0'
implementation 'com.android.support:support-compat:26.1.0'
implementation 'com.android.support:appcompat-v7:26.1.0'
**implementation 'com.google.android.gms:play-services-analytics:12.0.1'**
}
..
to:
..
dependencies {
implementation 'com.android.support:multidex:1.0.3'
implementation 'com.android.support:support-v4:26.1.0'
implementation 'com.android.support:support-compat:26.1.0'
implementation 'com.android.support:appcompat-v7:26.1.0'
**implementation 'com.google.android.gms:play-services-analytics:16.0.5'**
}
..
There was no other changes in my code, but the fixed version worked on 4.x emulators too. Only the ** marked lines are changed.
In my case its solved by changes below code in Manifest from
android:name="android.support.multidex.MultiDexApplication"
to
android:name="androidx.multidex.MultiDexApplication"
I was using the latest Android Studio and following the official document to add support to multidex https://developer.android.com/studio/build/multidex.html . But I still got the same exception. I spent a lot of time solving it. At last, I found the cause was I enabled "Java Exception Breakpoints - Any exception", and "Exception Breakpoints - When any is thrown". After I disabled them, the app ran without problems.
Just follow the official document about multidex https://developer.android.com/studio/build/multidex.html . It works.
This worked for me.
File -> Sync Project with Grandle Files
In my case I just changed the build.gradle and I leaved the AndroidManifest like that:
android:name=".MainApplication"
I am using React Native.
For me, the answer was to switch to the androidx versions
android:name="androidx.multidex.MultiDexApplication"
implementation "androidx.multidex:multidex:2.0.1"