【问题标题】:Image-Cropper Gradle issueImage-Cropper Gradle 问题
【发布时间】:2018-08-19 11:53:30
【问题描述】:

我正在使用这个库here,我在一个项目中使用了它,现在它工作正常,现在我在另一个项目中使用它并且在构建它时会引发错误

错误:任务 ':app:transformClassesWithMultidexlistForDebug' 执行失败。 java.io.IOException: 无法写入 [D:\Work\TeqniaTech\Morstan-Doctor\app\build\intermediates\multi-dex\debug\componentClasses.jar](无法读取 [C:\Users\AbdallahGaber .gradle\caches\transforms-1\files-1.1\support-core-ui-27.1.0.aar\d05e3ddb1fe5f53fdf878524820d2b3c\jars\classes.jar(;;;;;;**.class)] (重复的 zip 条目 [ classes.jar:android/support/design/widget/CoordinatorLayout$Behavior.class]))

这是我的 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'

对于 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'

我用了2天没找到问题所在,谁能帮忙

编辑: 我认为图书馆导致冲突,但我不知道它是什么,请提供任何线索??

【问题讨论】:

标签: android gradle android-gradle-plugin build.gradle


【解决方案1】:

我遇到了问题

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

我改成

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

编译成功

【讨论】:

    【解决方案2】:

    我遇到了类似的问题。但后来我发现有一个库导致了这个问题。

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

    是的。图像裁剪库。当我在同步后评论该行并运行项目时,它对我有用。

    现在,如何解决这个问题?我发现一些用户已经在 Git Link 中发布了这个问题。请通过下面的链接,它可能会帮助你。

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

    如该帖子中所述。

    原因 这是因为该库包含 27.+ 版本的支持库。支持库 27.1.0 已于昨天发布,并自动包含在您的项目中,并带有您自己定义的另一个版本。该库不能定义动态版本!

    解决方案 您应该强制所有支持库使用相同的版本。

    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
                }
            }
        }
    }
    

    或者,您可以将库版本从2.6.+ 降级为2.5.+

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

    【讨论】:

    • 我今天进入说对我有用的答案,你是绝对正确的,当我尝试为签名 APK 构建另一个应用程序时,我发现了同样的错误,然后我自己嵌入了库,看到后修改了代码,意识到版本不匹配是问题,问题解决了,谢谢Man :)
    • @AbdallahGaber 很高兴为您提供帮助 :)
    猜你喜欢
    • 1970-01-01
    • 2016-08-28
    • 2018-01-29
    • 2021-08-07
    • 2021-03-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多