Multidex issue for androidTest with gradle 3.0.0 plugin

As soon as I updated the application to gradle plugin 3.0.0, I had a problem with multidex, but only when running androidTest .

My application was already multidex and with the gradle 2.3.3 plugin both assembleDebug and assembleDebugAndroidTest worked fine. Then I just upgraded the gradle plugin to 3.0.0, and I started getting the following exception:

com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536

I tried various parameters, for example, defining a custom multi-user runner for tests, adding the dependency androidTestCompile 'com.android.support:multidex-instrumentation:1.0.2' , but nothing helped. I also did not find in the gradle plugin 3.0.0 release notes if something changed there for Android tests.

Does anyone have a similar problem for androidTest ?

+5
source share
1 answer

I believe this is a known issue: https://issuetracker.google.com/issues/37324038

The problem is that legacy multidex (min API <21) is not supported in Android Gradle plugin 3.0.0 for androidTest APK specifically. I managed to get it working by creating a flavor of the product min API> = 21, for example:

 productFlavors { local { minSdkVersion 21 } ci { minSdkVersion 17 } } 

And then running androidTests using the related task LocalDebugAndroidTest

+4
source

Source: https://habr.com/ru/post/1273401/


All Articles