我在执行时间得到错误

时间:2017-07-25 08:01:50

标签: java android build.gradle gmail-api

错误讯息
              `错误:任务执行失败         ':应用程序:transformClassesWithJarMergingForDebug'。

  

com.android.build.api.transform.TransformException:java.util.zip.ZipException:重复条目:com / google / common / annotations / Beta.class`

的build.gradle(Module.app)

    apply plugin: 'com.android.application'

    android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
    applicationId "com.example.jd.travelsdemo"
    minSdkVersion 19
    targetSdkVersion 25
    multiDexEnabled true
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    configurations.all {
        resolutionStrategy {
            force 'com.google.code.findbugs:jsr305:1.3.9', 'com.google.code.findbugs:jsr305:2.0.1'
        }
    }
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
   }

    dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
    exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:design:25.3.1'
compile 'com.android.support:support-v4:25.3.1'
compile 'com.android.support:cardview-v7:25.3.1'
compile 'com.github.clans:fab:1.6.4'
compile 'com.basgeekball:awesome-validation:2.0'
//gmail api dependencies
compile 'com.google.android.gms:play-services-auth:10.2.4'
compile('com.google.api-client:google-api-client-android:1.22.0') {
    exclude group: 'org.apache.httpcomponents'
}
compile('com.google.apis:google-api-services-gmail:v1-rev44-1.22.0') {
    exclude group: 'org.apache.httpcomponents'

}

compile 'junit:junit:4.12'
   }

2 个答案:

答案 0 :(得分:1)

compile('com.google.api-client:google-api-client-android:1.22.0') {
    exclude group: 'org.apache.httpcomponents'
    exclude group:'com.google.guava'
}
compile('com.google.apis:google-api-services-gmail:v1-rev67-1.22.0') {
    exclude group: 'org.apache.httpcomponents'
    exclude group:'com.google.guava'

}

如上所述添加了排除组。

答案 1 :(得分:0)

尝试使用以下代码

排除重复的文件
packagingOptions {
    exclude 'META-INF/DEPENDENCIES'
    exclude 'META-INF/NOTICE'
    exclude 'META-INF/LICENSE'
    exclude 'META-INF/LICENSE.txt'
    exclude 'META-INF/NOTICE.txt'
    pickFirst  'META-INF/license.txt'
        }