Gradle构建错误:重复输入 [英] Gradle build error : Duplicate entry

查看:268
本文介绍了Gradle构建错误:重复输入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的gradle文件是

My gradle file is

apply plugin: 'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion "24.0.0 rc2"

defaultConfig {
    applicationId "com.test.test"
    minSdkVersion 15
    targetSdkVersion 23
    versionCode 1
    versionName "1.0"
    multiDexEnabled true
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
}

buildscript {
repositories {
    mavenCentral()
    jcenter()
}

dependencies {
    classpath 'com.android.tools.build:gradle:2.1.0'
    classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3'
}
}

repositories {
mavenCentral()
jcenter()
flatDir {
    dirs '../libs'
}
}



dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.3.0'
compile('com.google.android.gms:play-services:8.4.0') {
    exclude group: 'com.google.guava'
}
compile ('org.apache.httpcomponents:httpcore:4.4.4')
        {
            exclude group: 'org.apache.http.annotation.NotThreadSafe'
        }
compile 'commons-io:commons-io:2.4'
compile 'com.android.support:support-annotations:23.0.0'
compile 'com.android.support:recyclerview-v7:23.0.0'
compile 'com.google.android.exoplayer:exoplayer:r1.4.2'
compile 'com.mopub.volley:mopub-volley:1.1.0'
compile 'com.android.support:multidex:1.0.0'
}

我在编译应用程序时遇到这个错误

And I am getting this error while compiling the application

错误:任务':myapplication:transformClassesWithJarMergingForDebug'的执行失败。
com.android.build.api.transform.TransformException:
java.util.zip.ZipException:重复条目:org / apache / http / annotation / NotThreadSafe.class

任何人都可以告诉我需要从依赖列表中排除什么。或者任何解决方案的问题?

Can anyone please tell me what I need to exclude from the dependency list. Or any solution for the problem ?

推荐答案

修改你的gradle是这样的:

Modify your gradle like this:

apply plugin: 'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion "24.0.0 rc2"

defaultConfig {
    applicationId "com.test.test"
    minSdkVersion 15
    targetSdkVersion 23
    versionCode 1
    versionName "1.0"
    multiDexEnabled true
}

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

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

buildscript {
repositories {
    mavenCentral()
    jcenter()
}

dependencies {
    classpath 'com.android.tools.build:gradle:2.1.0'
    classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3'
}
}

repositories {
mavenCentral()
jcenter()
flatDir {
    dirs '../libs'
}
}



dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.3.0'
compile('com.google.android.gms:play-services:8.4.0') {
    exclude group: 'com.google.guava'
}
compile ('org.apache.httpcomponents:httpcore:4.4.4')
        {
            exclude group: 'org.apache.http.annotation.NotThreadSafe'
        }
compile 'commons-io:commons-io:2.4'
compile 'com.android.support:support-annotations:23.0.0'
compile 'com.android.support:recyclerview-v7:23.0.0'
compile 'com.google.android.exoplayer:exoplayer:r1.4.2'
compile 'com.mopub.volley:mopub-volley:1.1.0'
compile 'com.android.support:multidex:1.0.0'
}

packagingOptions 可让您使用重复的类。这意味着如果两个库具有相同的类名,那么编译器会忽略它。

the packagingOptions will let you use duplicate classes. That means if two libraries having same class names then compiler will ignore that.

这篇关于Gradle构建错误:重复输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆