Reputation: 1336
My app is under the dex limit for regular builds, but is giving the dex limit build error for test builds:
Conversion to Dalvik format failed:
Unable to execute dex: method ID not in [0, 0xffff]: 65536
It seems to be because of the addition of these libraries for testing:
androidTestCompile 'org.mockito:mockito-core:1.10.19'
androidTestCompile 'org.powermock:powermock-api-mockito:1.6.5'
androidTestCompile 'org.powermock:powermock-module-junit4:1.6.5'
I know that I could go to multidex builds, but I want to avoid it as long as possible so that my build times don't go up - it would be a last resort. I also can't set the minSdkVersion to 21 for debug builds since I'm targeting API 19 devices. I would really like to continue using the above libraries - there is no good alternative to these.
Is there anything I can do under my gradle configuration to limit multidex to just the test builds? Or any other possible solution for this?
Upvotes: 2
Views: 367
Reputation: 7311
Try this in your build script and let proguard shrink your code:
android {
buildTypes {
debugTest.initWith(debug)
debugTest {
minifyEnabled true
}
}
}
...
android {
testBuildType 'debugTest'
}
Adopted from stackoverflow.com/questions/21463089/proguard-gradle-debug-build-but-not-the-tests
Upvotes: 1
Reputation: 317467
You can create a new build flavor just for testing/developing on high api levels. It would look something like this:
android {
productFlavors {
testing {
minSdkVersion 21
}
}
}
You can put into your custom "testing" flavor any configurations that you would also put into defaultConfig.
After you define this, you can switch to this flavor in Android Studio using the Build Variants tool window in the bottom left. And you can build it with gradle with assembleTestingDebug
. You can define as many flavors as you need different configurations that are convenient for you.
http://tools.android.com/tech-docs/new-build-system/user-guide
Upvotes: 0