Image-Cropper Gradle issue

2019-09-21 18:48发布

I am using this library here and I used it in a project and it works fine now I am using it in another project and in build it fires an error

Error:Execution failed for task ':app:transformClassesWithMultidexlistForDebug'. java.io.IOException: Can't write [D:\Work\TeqniaTech\Morstan-Doctor\app\build\intermediates\multi-dex\debug\componentClasses.jar] (Can't read [C:\Users\AbdallahGaber.gradle\caches\transforms-1\files-1.1\support-core-ui-27.1.0.aar\d05e3ddb1fe5f53fdf878524820d2b3c\jars\classes.jar(;;;;;;**.class)] (Duplicate zip entry [classes.jar:android/support/design/widget/CoordinatorLayout$Behavior.class]))

and here is my 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'

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

android {
    compileSdkVersion 26
    buildToolsVersion "26.0.2"
    defaultConfig {
        applicationId "com.teqnia_tech.morstan_doctor"
        minSdkVersion 17
        targetSdkVersion 26
        versionCode 1
        versionName "0.0.1"
        multiDexEnabled true
    }

    dexOptions {
        javaMaxHeapSize "4g"
    }

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

    aaptOptions {
        cruncherEnabled = false
    }
}

dependencies {
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    compile fileTree(dir: 'libs', include: ['*.jar'])

    compile 'com.android.support:appcompat-v7:26.0.2'
    compile 'com.android.support:design:26.0.2'
    compile 'com.android.support:support-v4:26.0.2'

    //location google play service
    compile 'com.google.android.gms:play-services-location:11.0.1'

    //picasso
    compile 'com.squareup.picasso:picasso:2.5.2'

    //Twitter
    compile 'com.twitter.sdk.android:twitter:3.1.1'

    //Timber
    compile 'com.jakewharton.timber:timber:4.1.0'

    //Butterknife
    annotationProcessor 'com.jakewharton:butterknife-compiler:8.4.0'
    compile 'com.jakewharton:butterknife:8.8.1'

    //Date and time
    compile 'joda-time:joda-time:2.9.9'

    // network
    compile 'com.squareup.retrofit2:retrofit:2.0.0'
    compile 'com.squareup.retrofit2:converter-gson:+'
    compile 'com.squareup.okhttp3:logging-interceptor:3.0.1'
    compile 'com.squareup.okhttp3:okhttp:3.7.0'

    //Twitter
    compile('com.twitter.sdk.android:twitter:2.3.2@aar') {
        transitive = true;
    }

    //Facebook SDK
    compile 'com.facebook.android:facebook-android-sdk:4.23.+'

    // for cropping and selecting image
    compile 'com.theartofdev.edmodo:android-image-cropper:2.6.0'

    //Firebase
    compile 'com.google.firebase:firebase-core:11.0.1'
    compile 'com.google.firebase:firebase-messaging:11.0.1'
    compile 'com.google.firebase:firebase-database:11.0.1'

    //Multidex
    compile 'com.android.support:multidex:1.0.1'

    testCompile 'junit:junit:4.12'
    compile('com.crashlytics.sdk.android:crashlytics:2.8.0@aar') {
        transitive = true;
    }
}
//Map
apply plugin: 'com.google.gms.google-services'

and For the project that worked that is the Gradle :

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

    dependencies {
        classpath 'io.fabric.tools:gradle:1.+'
    }
}
apply plugin: 'com.android.application'
apply from: "${project.rootDir}/QA/quality.gradle"
apply plugin: 'io.fabric'

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

android {
    compileSdkVersion 26
    buildToolsVersion '26.0.2'

    defaultConfig {
        applicationId "com.teqnia_tech.morstan"
        minSdkVersion 17
        targetSdkVersion 26
        versionCode 22
        versionName "0.5.5"
        multiDexEnabled true
    }

    dexOptions {
        javaMaxHeapSize "4g"
    }

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

dependencies {
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    compile fileTree(include: ['*.jar'], dir: 'libs')
    // general
    compile 'com.android.support:appcompat-v7:26.0.2'
    compile 'com.android.support:mediarouter-v7:26.0.2'
    compile 'com.android.support:customtabs:26.0.2'
    compile 'com.android.support:cardview-v7:26.0.2'
    compile 'com.android.support:design:26.0.2'
    compile 'com.android.support:support-v4:26.0.2'
    compile 'com.google.android.gms:play-services-maps:11.0.1'
    compile 'com.google.android.gms:play-services:11.0.1'
    annotationProcessor 'com.jakewharton:butterknife-compiler:8.4.0'
    compile 'com.jakewharton:butterknife:8.8.1'
    compile 'com.jakewharton.timber:timber:4.1.0'
    // inspection
    compile 'com.facebook.stetho:stetho:1.3.0'
    compile 'com.facebook.stetho:stetho-okhttp3:1.3.0'
    //Facebook SDK
    compile 'com.facebook.android:facebook-android-sdk:4.23.+'
    // network
    compile 'com.squareup.retrofit2:retrofit:2.0.0'
    compile 'com.squareup.retrofit2:converter-gson:+'
    compile 'com.squareup.okhttp3:logging-interceptor:3.0.1'
    compile 'com.squareup.okhttp3:okhttp:3.7.0'
    // tests
    testCompile 'junit:junit:4.12'
    testCompile 'org.mockito:mockito-core:1.+'
    //Twitter
    compile('com.twitter.sdk.android:twitter:2.3.2@aar') {
        transitive = true;
    }
    //location google play service
    compile 'com.google.android.gms:play-services-location:11.0.1'
    //picasso and rounded image
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'com.makeramen:roundedimageview:2.3.0'
    compile('com.crashlytics.sdk.android:crashlytics:2.6.7@aar') {
        transitive = true;
    }
    //Date and time
    compile 'joda-time:joda-time:2.9.9'
    //rtl viewpager
    //    compile 'klogi.com:rtlviewpager:1.0.0'
    //Banner slider
    compile 'com.ss.bannerslider:bannerslider:1.8.0'
    //font changer
    //    compile 'uk.co.chrisjenx:calligraphy:2.2.0'
    compile 'me.anwarshahriar:calligrapher:1.0'
    //Searchable spinner
    //    compile 'com.github.MdFarhanRaja:SearchableSpinner:1.7'
    //Firebase
    compile 'com.google.firebase:firebase-core:11.0.1'
    compile 'com.google.firebase:firebase-messaging:11.0.1'
    compile 'com.google.firebase:firebase-database:11.0.1'
    //Multidex
    compile 'com.android.support:multidex:1.0.1'

    //flexable layout
    compile 'com.google.android:flexbox:0.3.2'

    // for filter enhancing
    compile 'com.jakewharton.rxbinding2:rxbinding-appcompat-v7:2.0.0'

    // for cropping and selecting image
    compile 'com.theartofdev.edmodo:android-image-cropper:2.6.+'

    //AppIntro
    compile 'com.github.apl-devs:appintro:v4.2.0'
    compile project(':Spotlight-library')
    compile project(':rtlviewpager')
    compile project(':spinerdialog')
}

//Map
apply plugin: 'com.google.gms.google-services'

I spent 2 days and I can't find what is the problem , can anyone help

Edit: I think the library cause conflict but I can't know what is it, any clue please??

2条回答
甜甜的少女心
2楼-- · 2019-09-21 19:32

I was facing issues with

dependencies {
api 'com.theartofdev.edmodo:android-image-cropper:2.8.+'
}

I changed to

dependencies {
api 'com.theartofdev.edmodo:android-image-cropper:2.5.+'
}

It compiled successfully

查看更多
叼着烟拽天下
3楼-- · 2019-09-21 19:35

I was facing similar problem. But later on I found out that there is one library which is causing that issue.

compile 'com.theartofdev.edmodo:android-image-cropper:2.6.+'

Yes. Image Cropping library. When I commented that line and run project after sync, it worked for me.

Now, how to solve that thing? I have found out that some users already posted this issue in Git Link. Please go through below link, it might help you.

https://github.com/ArthurHub/Android-Image-Cropper/issues/495

As Described in that post.

Reason This is due to the fact that this library includes support libraries with 27.+ version. Support library 27.1.0 was released yesterday and is automatically included in your project with another version defined by yourself. The lib must not define dynamic version!

Solution You should force all of your support libraries to use the same version.

configurations.all {
    resolutionStrategy {
        eachDependency { details ->
            // Force all of the primary support libraries to use the same version.
            if (details.requested.group == 'com.android.support'
                    && details.requested.name != 'multidex'
                    && details.requested.name != 'multidex-instrumentation') {
                details.useVersion supportLibraryVersion
            }
        }
    }
}

or, You can downgrade library version from 2.6.+ to 2.5.+

compile 'com.theartofdev.edmodo:android-image-cropper:2.5.+'
查看更多
登录 后发表回答