Multidex issue for androidTest with gradle plugin 3.0.0
Asked Answered
P

1

7

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?

Placative answered 15/11, 2017 at 14:15 Comment(0)
C
5

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

Conner answered 16/11, 2017 at 1:53 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.