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

后端 未结 2 758
攒了一身酷
攒了一身酷 2020-12-06 22:39

I have a problem in my android project. I recently upgraded from lower version and then rebooted my OS with Linux. My project was working fine. But, now as I have compiled,

相关标签:
2条回答
  • 2020-12-06 23:10

    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.

    0 讨论(0)
  • 2020-12-06 23:23

    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

    0 讨论(0)
提交回复
热议问题