在运行代码时出现错误,我尝试了MultidexEnable但没有工作

时间:2017-10-26 09:15:23

标签: java android

错误:任务执行失败':app:transformClassesWithMultidexlistForDebug'。

  

java.io.IOException:无法写[/home/android1/Android/projects/ezeparents/app/build/intermediates/multi-dex/debug/componentClasses.jar](无法读取[/ home / android1 / .gradle / caches / modules-2 / files-2.1 / org.apache.httpcomponents / httpcore / 4.3.2 / 31fbbff1ddbf98f3aa7377c94d33b0447c646b6e / httpcore-4.3.2.jar(;;;;;; **。class)](重复的zip条目[httpcore-4.3.2.jar:org / apache / http / annotation / NotThreadSafe.class]))

的build.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.ezeparents"
        minSdkVersion 16
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
        multiDexEnabled = true
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    android {

        packagingOptions {
            exclude 'META-INF/DEPENDENCIES'
            exclude 'META-INF/NOTICE'
            exclude 'META-INF/LICENSE'
            exclude 'META-INF/LICENSE.txt'
            exclude 'META-INF/NOTICE.txt'
            exclude 'META-INF/ECLIPSE_.SF'
            exclude 'META-INF/ECLIPSE_.RSA'
            exclude  'org/apache/http/annotation/NotThreadSafe.class'

        }


    }


}
configurations {
    all*.exclude group: 'xpp3', module: 'xpp3'
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })

    compile('com.crashlytics.sdk.android:crashlytics:2.6.7@aar') {
        transitive = true;
    }

    compile 'com.github.nguyenhoanglam:ImagePicker:1.2.1'
    compile 'com.roomorama:caldroid:3.0.1'
    compile 'com.android.support:appcompat-v7:26.0.1'
    compile 'com.android.support:design:26.0.1'
    compile 'com.github.scottyab:showhidepasswordedittext:0.8'
    compile 'com.android.support:recyclerview-v7:26.0.1'
    compile 'com.android.support:cardview-v7:26.0.1'
    compile 'me.relex:circleindicator:1.2.2@aar'
    compile 'com.hedgehog.ratingbar:app:1.1.2'
    compile 'com.squareup.okhttp3:okhttp:3.8.1'
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'com.facebook.android:facebook-android-sdk:4.+'
    compile 'de.hdodenhof:circleimageview:2.1.0'
    compile 'com.github.fiskurgit:ChipCloud:2.1.0'
    compile 'com.squareup.retrofit2:converter-gson:2.3.0'
    compile 'com.theartofdev.edmodo:android-image-cropper:2.3.+'
    compile 'com.kyleduo.switchbutton:library:1.4.4'
    compile 'com.getkeepsafe.taptargetview:taptargetview:1.9.1'
    compile 'com.android.support.constraint:constraint-layout:1.0.1'
    compile 'com.google.firebase:firebase-messaging:11.4.2'
    compile 'com.google.android.gms:play-services-auth:11.4.2'
    compile 'com.google.android.gms:play-services-location:11.4.2'
    compile 'com.google.android.gms:play-services-places:11.4.2'
    compile 'org.igniterealtime.smack:smack-android:4.1.0-rc1'
    compile 'org.igniterealtime.smack:smack-tcp:4.1.0-rc1'
    compile 'org.igniterealtime.smack:smack-android-extensions:4.1.0-rc1'
    compile 'com.android.volley:volley:1.0.0'
    compile 'com.googlecode.android-query:android-query:0.24.3'
    compile 'org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2'
    compile 'com.google.firebase:firebase-auth:11.4.2'
    compile 'uk.co.chrisjenx:calligraphy:2.3.0'
    testCompile 'junit:junit:4.12'
    compile 'com.github.nguyenhoanglam:ImagePicker:1.2.1'
    compile 'com.github.hani-momanii:SuperNova-Emoji:1.1'
    compile 'org.apache.commons:commons-lang3:3.5'
    compile 'com.android.support:multidex:1.0.2'
}

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

2 个答案:

答案 0 :(得分:1)

请清除你的依赖关系。您有一个错误,因为您有很多具有相同功能的库。 还

警告:警告:依赖org.apache.httpcomponents:httpclient:4.3.2因发布而被忽略,因为它可能与Android提供的内部版本冲突。

在我看来,问题在于

compile 'com.squareup.retrofit2:retrofit:2.3.0'
compile 'org.apache.commons:commons-lang3:3.5'

这两个库可以具有相同的类,因此您需要排除其中一个,或者排除这些重复项。 你可以尝试

android {

...


    packagingOptions {
           exclude  'org/apache/http/annotation/NotThreadSafe.class'
    }
}

相同的主题(Gradle build error : Duplicate entry

答案 1 :(得分:0)

上述答案也可能是正确的,但似乎也是新谷歌回购的问题

添加谷歌,如下所示

在根级别gradle.build使用下面的

buildscript {
    repositories {
        mavenCentral()
        jcenter()
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.0'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        mavenCentral()
        jcenter()
        google()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

并在gradle-wrapper.properties文件中更改包装器版本,如下所示

distributionUrl=https\://services.gradle.org/distributions/gradle-4.2.1-all.zip