com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex - Android Studio 3.0 stable

梦想的初衷 提交于 2019-12-03 02:26:33

I know it's too late to update.I had same issue on my project.

Possible Reasons

  1. If you have added module in your project and that module has support libraries or any google play services libs which has different version then your app.
  2. If you are using any open source library in your project and that library internally using any of libraries that your are also using in your project.

Solutions

  • If it is case 1 in your project then update your library versions and make it same in your project and module.
  • Check your dependencies tree using below command and see if any mismatch in dependencies.

    ./gradlew :app:dependencies
    
  • You can exclude particular module from any dependencies like below.

    implementation('com.google.android.ads.consent:consent-library:1.0.4') {
      transitive = true
      exclude group: "com.android.support"
    } 
    
  • In above example, It will exclude the com.android.support group from consent-library dependencies.

  • You can also remove particular module as well.

     compile ('junit:junit:4.12'){
      exclude group: 'org.hamcrest', module:'hamcrest-core'
      }
    
  • In above example it will exclude hamcrest-core from org.hamcrest.

I got the same problem, adding sourceCompatibility and targetCompatibility to my build.gradle helped me:

android {
    compileOptions {
        sourceCompatibility 1.8
        targetCompatibility 1.8
    }
}

I was having a fit with this, and none of the answers I found worked. Finally found a solution -- sharing it here although I can't tell you definitively how to find which is the offending dependency -- maybe you'll have to do some trial and error.

In my build.gradle (Module:app) I added this exclude clause:

    compile ('org.eclipse.paho:org.eclipse.paho.android.service:1.0.2')
        { exclude module: 'support-v4' }
mohammed alshaarawi

I did exact as the hint in the image except changed 11.0.4 to 11.8.0

compile 'com.google.android.gms:play-services-base:11.8.0'
compile 'com.google.android.gms:play-services:11.8.0'

in my case i change all com.android.support: libraries to 27.1.0 and it works

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