multiDexEnabled do not work

岁酱吖の 提交于 2019-12-10 11:24:34

问题


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.

Ok, I found the multiDexEnabled property and added

multiDexEnabled true

in the

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.

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

回答1:


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'
            }
        }
    }

...
}


来源:https://stackoverflow.com/questions/26883649/multidexenabled-do-not-work

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!