"Unable to merge dex" when using room

Viewed 973

I'm trying to add a "room" to my project.

When I try to build a project, I get an error:

Error:Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'. java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex

What I have already done:

  1. Clean/Rebuild project
  2. I added "multiDexEnabled true" in defaultConfig{}. Then I get the error:

    Error:Execution failed for task ':app:transformClassesWithMultidexlistForDebug'. java.io.IOException: Can't write [C:\Users\user1\AndroidStudioProjects\git\mobile\app\build\intermediates\multi-dex\debug\componentClasses.jar] (Can't read [C:\Users\user1.gradle\caches\transforms-1\files-1.1\support-core-utils-26.1.0.aar\a6c34f6784b0b6bc5c2fc7a7815426da\jars\classes.jar(;;;;;;**.class)] (Duplicate zip entry [classes.jar:android/support/v4/content/PermissionChecker$PermissionResult.class]))

If I remove the "room" from my project, it is build without errors.

I'm using Android Studio 3, gradle build tools 3.0.0.

This is my build.gradle:

apply plugin: 'com.android.application'
apply plugin: 'me.tatarka.retrolambda'

buildscript {
   repositories {
       mavenCentral()
   }

   dependencies {
       classpath 'me.tatarka:gradle-retrolambda:3.2.5'
   }
}

repositories {
    mavenCentral()
}

android {
   compileSdkVersion 23
   buildToolsVersion '26.0.2'

   defaultConfig {
        applicationId "trsnet.gtp2.com"
        minSdkVersion 17
        targetSdkVersion 23
        multiDexEnabled true
   }

   buildTypes {
       release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 
                'proguard-rules.txt'
       }
   }

   compileOptions {
       sourceCompatibility JavaVersion.VERSION_1_8
       targetCompatibility JavaVersion.VERSION_1_8
   }

}

dependencies {

    compile files('libs/commons-codec-1.9.jar')
    compile files('libs/ksoap2-android-assembly-3.0.0-jar-with-
    dependencies.jar')
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:cardview-v7:23.2.1'
    compile 'com.android.support:appcompat-v7:23.2.1'
    compile 'com.android.support:design:23.2.1'
    compile 'com.android.support.constraint:constraint-layout:+'
    compile 'io.reactivex:rxandroid:1.2.1'
    compile 'io.reactivex:rxjava:1.1.6'
    compile 'com.jakewharton.rxbinding:rxbinding:0.4.0'
    implementation 'android.arch.persistence.room:runtime:1.0.0'
    annotationProcessor 'android.arch.persistence.room:compiler:1.0.0'
}
1 Answers
Related