【问题标题】:Getting Error while running code, I tried MultidexEnable but didnt work运行代码时出错,我尝试了 MultidexEnabled 但没有用
【发布时间】:2017-10-26 09:15:23
【问题描述】:

错误:任务 ':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'

【问题讨论】:

  • 需要更多信息。请附上gradle构建文件。
  • 我想你对 apache httpcomponens 有问题。尝试清除项目,然后重新运行 gradle sync。也尝试检查这个问题(重复的 zip 条目 [httpcore-4.3.2.jar:org/apache/http/annotation/NotThreadSafe.class])))
  • @MykhailoVoloshyn 今天我将我的 android studio 升级到 3.0,此后我遇到了这个问题。我已经启用了 multiDexEnabled = true 并且还清理了我的项目。运行应用程序而不是同步时仍然面临同样的问题。
  • 请在您的 lib 文件夹中附上库名称
  • @AbuQauod 我没有任何 jar 依赖

标签: java android


【解决方案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)

【讨论】:

  • 感谢您的建议,但它对我不起作用。我根据您的建议升级了我的 gradle。请检查一下
  • 工作:编译('org.apache.httpcomponents:httpcore:4.4.4'){排除组:'org.apache.http.annotation.NotThreadSafe'}没有工作:编译'org .jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2'
【解决方案2】:

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

如下添加谷歌

在你的根级别 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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-10-05
    • 2014-05-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-06-06
    相关资源
    最近更新 更多