0

I'm getting this error when I try to build my APK. I'm currently mantaining and buf-fixing this app from another developer. In the gradle he used .+ in every compile. How can I fix it?

The Error: Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.

com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: android/support/design/widget/CoordinatorLayout.class

The gradle:

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'
apply plugin: 'realm-android'

repositories {
    maven { url 'https://maven.fabric.io/public' }
}

android {
    compileSdkVersion 26
    buildToolsVersion '26.0.2'
    defaultConfig {
        applicationId "com.easyfixapp.easyfix"
        minSdkVersion 15
        targetSdkVersion 26
        multiDexEnabled true
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    configurations.all {
        resolutionStrategy {
            force 'com.google.code.findbugs:jsr305:3.0.1'
        }
    }
}

realm {
    syncEnabled = true;
}
repositories {
    mavenCentral()
}
dependencies {
    compile('com.facebook.android:facebook-android-sdk:[4,5)') {
        exclude group: 'com.android.support', module: 'multidex'
    }
    compile fileTree(include: ['*.jar'], dir: 'libs')
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.theartofdev.edmodo:android-image-cropper:2.6.+'
    compile 'com.android.support:multidex:1.0.1'
    compile 'com.android.support:appcompat-v7:26.+'
    compile 'com.android.support:support-v4:26.+'
    compile 'com.android.support:design:26.+'
    compile 'com.android.support:support-vector-drawable:26.+'
    compile 'com.android.support:cardview-v7:26.+'
    compile 'com.android.support:recyclerview-v7:26.+'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    compile 'com.android.support:mediarouter-v7:26.+'
    compile 'com.google.android.gms:play-services:11.6.0'
    compile 'com.google.firebase:firebase-messaging:11.6.0'
    compile 'com.prolificinteractive:material-calendarview:1.4.3'
    compile 'com.hbb20:ccp:2.0.5'
    compile 'com.squareup.retrofit2:retrofit:2.3.0'
    compile 'com.squareup.retrofit2:converter-gson:2.3.0'
    compile 'de.hdodenhof:circleimageview:2.2.0'
    compile 'uk.co.chrisjenx:calligraphy:2.3.0'
    compile 'com.github.bumptech.glide:glide:4.2.0'
    compile 'com.nineoldandroids:library:2.4.0'
    compile 'com.github.chrisbanes:PhotoView:2.0.0'
    compile('com.crashlytics.sdk.android:crashlytics:2.8.0@aar') {
        transitive = true;
    }
    annotationProcessor 'com.github.bumptech.glide:compiler:4.2.0'
    testCompile 'junit:junit:4.12'
}

apply plugin: 'com.google.gms.google-services'
G.Lunn
  • 1
  • Try setting them to the latest versions of each of the compiled libraries. I've found the "+" never seems to work out well, myself. – rjr-apps Mar 05 '18 at 22:10

1 Answers1

1
  1. Remove all of the "+" in your libraries dependency's version
  2. Try this in your app level gradle file

    implementation('com.github.bumptech.glide:glide:4.6.1') {
    exclude group: 'com.android.support'
    }`
    

    if it does not solve try logging dependencies run this command

    ./gradlew -q dependencies app:dependencies --configuration compile
    

    in your android studio's Terminal Tab it will log all the dependency tree of your project

then find which libraries are using duplicating dependencies

for example

implementation 'com.github.bumptech.glide:glide:4.6.1' 

is using duplicate dependencies so change

 implementation 'com.github.bumptech.glide:glide:4.6.1'

to

implementation('com.github.bumptech.glide:glide:4.6.1') {
exclude group: 'com.android.support'
}
Pang
  • 9,564
  • 146
  • 81
  • 122
SAKhan
  • 249
  • 4
  • 16