Once I updated my app to gradle plugin 3.0.0 I started having issue with multidex, but only when I run androidTest
.
My app was already multidex and with gradle plugin 2.3.3 both assembleDebug
and assembleDebugAndroidTest
were working fine. Then I just updated gradle plugin to 3.0.0 and I started receiving the following exception:
com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536
I tried different options like defining custom multidex runner for tests, adding androidTestCompile 'com.android.support:multidex-instrumentation:1.0.2'
dependency, but nothing helped. I also didn't find in release notes of gradle plugin 3.0.0, if something changed there for android tests.
Does anybody have similar issue for androidTest
?
I believe it is a known issue: https://issuetracker.google.com/issues/37324038
The issue is that legacy multidex (min API < 21) is not supported in Android Gradle plugin 3.0.0 for androidTest APK's specifically. I was able to get it working by making a product flavor with min API >= 21 like so:
productFlavors {
local {
minSdkVersion 21
}
ci {
minSdkVersion 17
}
}
And then running androidTests using the connectedLocalDebugAndroidTest task
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With