我的应用程序低于常规构建的 dex 限制,但给出测试构建的 dex 限制构建错误:
Conversion to Dalvik format failed:
Unable to execute dex: method ID not in [0, 0xffff]: 65536
好像是因为添加了这些库来测试:
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'
我知道我可以使用 multidex 构建,但我想尽可能避免它,这样我的构建时间就不会增加 - 这将是最后的手段。我也无法将调试版本的 minSdkVersion 设置为 21,因为我的目标是 API 19 设备。我真的很想继续使用上面的库——没有比这些更好的选择了。
在我的 gradle 配置下,我可以做些什么来将 multidex 限制为仅用于测试构建?或者任何其他可能的解决方案?
最佳答案
在你的构建脚本中试试这个,让 proguard 收缩你的代码:
android {
buildTypes {
debugTest.initWith(debug)
debugTest {
minifyEnabled true
}
}
}
...
android {
testBuildType 'debugTest'
}
采用自 stackoverflow.com/questions/21463089/proguard-gradle-debug-build-but-not-the-tests
关于android - 测试构建达到 65k 方法 dex 限制,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37553373/