Unable to merge DEX in Android Studio 3.0.1 even after enabling multidex

﹥>﹥吖頭↗ 提交于 2019-11-28 01:33:34

This isn't a multidex problem...it's a dependency merge conflict issue.

By the looks of it one of your dependencies has a sub-dependency on CoordinatorLayout but has specified a different version from the one which you are using. You can fix this by using a resolutionStrategy in your build.gradle to define the version of the support library to use.

First make a variable to define your support library version:

ext {
    supportLibVersion = "26.1.0"
}

Then update your dependences to use this variable rather than the hard coded value (note the double quotes):

implementation "com.android.support:appcompat-v7:${supportLibVersion}"
implementation "com.android.support:design:${supportLibVersion}"

Then you can add a resolutionStrategy to your build.gradle:

configurations.all {
    resolutionStrategy.eachDependency { details ->
        def requested = details.requested
        if (requested.group == 'com.android.support') {
            if (!requested.name.startsWith("multidex")) {
                details.useVersion "${supportLibVersion}"
            }
        }
    }
}

What this does is ask Gradle to ignore the version number specified in with the dependency and use your version.

sachinmaharjan

If your multidex is enabled and still causing problem. You may try changing the version of firebase. Try 11.8.0 and if it doesn't work. try 12.0.0 . Try to remove the unnecessary dependencies.

Adding implementation 'com.android.support:multidex:1.0.0' may also solve your problem

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