本文介绍了multiDexEnabled不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个相当大的android项目.该项目仍然可以编译,但是当我尝试编译测试时,我得到一个错误:
I have a rather large android project. The project still compiles, but when I try to compile tests I get an error:
Execution failed for task ':app:dexDebugTest'.
trouble writing output: Too many method references: 70561; max is 65536.
You may try using --multi-dex option.
好吧,我找到了multiDexEnabled属性并添加了
Ok, I found the multiDexEnabled property and added
multiDexEnabled true
在
defaultConfig
我还扩展了我的应用程序
Also I made my application extend
MultiDexApplication
但是它并没有改变任何东西,我还是得到
But it did not change anything, I still get
Execution failed for task ':logic:dexDebugTest'.
trouble writing output: Too many method references: 70561; max is 65536.
You may try using --multi-dex option.
它甚至显式地显示了不带--multi-dex参数的dx指令
And it even explicitly shows me the dx comand without --multi-dex parameter
sdk/build-tools/21.1.1/dx --dex --output /build/intermediates/dex/test/debug --input-list=build/intermediates/tmp/dex/test/debug/libraryList.txt
推荐答案
尝试将其添加到build.gradle
try adding this to your build.gradle
android{
...
afterEvaluate {
tasks.matching {
it.name.startsWith('dex')
}.each { dx ->
if (dx.additionalParameters == null) {
dx.additionalParameters = ['--multi-dex']
} else {
dx.additionalParameters += '--multi-dex'
}
}
}
...
}
这篇关于multiDexEnabled不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!