Android:构建APK文件时出现duplicati条目错误

时间:2016-04-26 04:14:27

标签: android multidex

当我为我的项目构建一个带有android studio(版本2.0)的APK文件时,出现错误:

  

错误:任务':app:transformClassesWithJarMergingForDebug'执行失败。   > com.android.build.api.transform.TransformException:java.util.zip.ZipException:重复条目:org / apache / oltu / oauth2 / common / OAuth $ ContentType.class

这是我的gradle文件:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"

    packagingOptions {
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
    }

    defaultConfig {
        applicationId "com.db.android.app.denhathai"
        minSdkVersion 15
        targetSdkVersion 23
        versionCode 14
        versionName "1.2.2"
        multiDexEnabled true

        manifestPlaceholders = [manifestApplicationId          : "${applicationId}",
                                onesignal_app_id               : "bad49395-e355-4802-8df1-414be2d345ac",
                                onesignal_google_project_number: "1071797880741"]
    }
    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    lintOptions {
        checkReleaseBuilds false
        abortOnError false
    }
    }

    dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:+'
    compile 'com.android.support:design:+'
    compile 'com.google.android.gms:play-services-ads:+'
    compile 'com.facebook.android:facebook-android-sdk:4.+'
    compile 'com.github.fengdai:alertdialogpro-theme-material:0.2.6'
    compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'
    compile 'com.onesignal:OneSignal:2.+@aar'
    compile 'com.google.android.gms:play-services-gcm:+'
    compile 'com.google.android.gms:play-services-analytics:+'
    compile 'com.google.android.gms:play-services-location:+'
    compile 'com.thefinestartist:finestwebview:1.2.1'
    compile 'com.squareup.okhttp3:okhttp:3.2.0'
    compile 'com.github.franmontiel:PersistentCookieJar:1c351f68d3'
    compile 'com.squareup.okhttp3:okhttp-urlconnection:3.0.0-RC1'
    compile 'org.apache.oltu.oauth2:org.apache.oltu.oauth2.client:1.0.1'
    }

3 个答案:

答案 0 :(得分:11)

尝试更改您的依赖

compile 'org.apache.oltu.oauth2:org.apache.oltu.oauth2.client:1.0.1'

compile ("org.apache.oltu.oauth2:org.apache.oltu.oauth2.client:1.0.1"){
    exclude group:'org.apache.oltu.oauth2' , module: 'org.apache.oltu.oauth2.common'
}

答案 1 :(得分:2)

这是因为您将库包含为compile dependency并将其包含在项目libs文件夹中。转到您的项目libs folder并删除重复的.jar文件。

答案 2 :(得分:1)

在终端执行根项目文件夹中:

./gradlew clean