Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multidex issue for androidTest with gradle plugin 3.0.0

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?

like image 766
brave_warrior Avatar asked Nov 15 '17 14:11

brave_warrior


1 Answers

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

like image 185
StiggyBr0 Avatar answered Nov 11 '22 22:11

StiggyBr0