title: Androidx migration getting DexArchiveMergerException: Unable to merge dex
body: <p>I've migrated to <code>androidx</code> and after a ton of time with it, I can't move away from the error below. I've integrated <code>multidex</code> but I still get the error.</p>
  
  <p>This is the exception:</p>
  
  <blockquote>
    <p>FAILURE: Build failed with an exception.<br></p>
  </blockquote>
  
  <p>What went wrong:</p>
  
  <blockquote>
    <p>Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForBetaDebug'.
    java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex</p>
  </blockquote>
  
  <p>I can't make it work. Here's my build.gradle. Any ideas?</p>
  
  <pre><code>    buildscript {
      repositories {
          maven { url 'https://maven.fabric.io/public' }
      }
  
      dependencies {
          classpath 'io.fabric.tools:gradle:1.+'
      }
  }
  apply plugin: 'com.android.application'
  apply plugin: 'io.fabric'
  
  repositories {
      maven { url 'https://maven.fabric.io/public' }
  }
  
  android {
  
      compileSdkVersion 28
      buildToolsVersion '27.0.3'
  
      signingConfigs {
          releaseSign {
              storeFile file("$rootProject.projectDir/keystore_release.jks")
              storePassword 'xxxxxxx'
              keyAlias 'xxxxxxx'
              keyPassword 'xxxxxxx'
          }
      }
  
      // Butterknife requires Java 8.
      compileOptions {
          sourceCompatibility JavaVersion.VERSION_1_8
          targetCompatibility JavaVersion.VERSION_1_8
      }
  
      defaultConfig {
          applicationId "com.xxxxxxx.xxxxxxx"
          minSdkVersion 19
          targetSdkVersion 28
          versionCode 10
          versionName "1.0.10"
  
          renderscriptTargetApi 19
          renderscriptSupportModeEnabled true
  
          multiDexEnabled true
      }
  
      buildTypes {
          release {
              minifyEnabled false
              proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
  
              signingConfig signingConfigs.releaseSign
          }
      }
  
      flavorDimensions "default"
      productFlavors {
          beta {
              applicationId "com.xxxxxxx.xxxxxxx.beta"
  
              dimension "default"
              resValue "string", "app_name", "xxxxxxx Beta"
  
              buildConfigField "String", "BASE_URL", '"http://xxxxxxx.net"'
              buildConfigField "Boolean", "IS_BETA", "true"
              buildConfigField "String", "TENANT", '"xxxxxxx"'
  
          }
          production {
              applicationId "com.xxxxxxx.driver"
  
              dimension "default"
              resValue "string", "app_name", "Driver"
  
              buildConfigField "String", "BASE_URL", '"http://apxxxxxxx"'
              buildConfigField "Boolean", "IS_BETA", "false"
              buildConfigField "String", "TENANT", '"xxxxxxx"'
          }
      }
  
      packagingOptions {
          exclude 'META-INF/NOTICE'
          exclude 'META-INF/LICENSE'
          exclude 'META-INF/notice'
          exclude 'META-INF/notice.txt'
          exclude 'META-INF/license'
          exclude 'META-INF/license.txt'
      }
  }
  
  dependencies {
      implementation fileTree(dir: 'libs', include: ['*.jar'])
      implementation 'androidx.appcompat:appcompat:1.1.0-alpha05'
  
      implementation 'androidx.cardview:cardview:1.0.0'
      implementation 'com.google.android.material:material:1.1.0-alpha06'
  
      implementation 'com.jakewharton:butterknife:10.1.0'
      annotationProcessor 'com.jakewharton:butterknife-compiler:10.1.0'
  
      implementation 'com.google.code.gson:gson:2.8.5'
      implementation 'me.grantland:autofittextview:0.2.1'
      implementation 'com.android.volley:volley:1.1.1'
      implementation 'org.greenrobot:eventbus:3.1.1'
      implementation 'com.github.ybq:Android-SpinKit:1.2.0'
  
      implementation 'com.google.android.gms:play-services-location:16.0.0'
  
      implementation 'com.crashlytics.sdk.android:crashlytics:2.10.0'
  
      implementation 'com.google.firebase:firebase-core:16.0.9'
      implementation 'com.google.firebase:firebase-messaging:18.0.0'
  
      implementation 'androidx.multidex:multidex:2.0.1'
  
      def work_version = "2.0.1"
      implementation "androidx.work:work-runtime:$work_version"
  // Optional - RxJava2 support
      implementation "androidx.work:work-rxjava2:$work_version"
  
      def futures_version = "1.0.0-beta01"
      implementation "androidx.concurrent:concurrent-futures:$futures_version"
  }
  
  apply plugin: 'com.google.gms.google-services'
  </code></pre>