【问题标题】:I get the error on Execution time我收到关于执行时间的错误
【发布时间】:2017-12-31 00:39:10
【问题描述】:

错误信息
` 错误:任务执行失败 ':app: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'
   }

【问题讨论】:

  • 您的第 3 方库之一正在使用您引用的库的不同版本。它应该在 android studio 中警告您存在不匹配。寻找您的一个依赖项,以橙色/米色突出显示
  • gradlew app:dependencies发布输出
  • 输出量大
  • compile 'com.github.clans:fab:1.6.4' 它使用库 compile 'com.android.support:appcompat-v7:23.3.0' @Doomsknight
  • 尝试将您的依赖项交换为23.3.0,然后构建,而不是25.3.1

标签: java android build.gradle gmail-api


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

}

如上所述添加排除组。

【讨论】:

    【解决方案2】:

    尝试使用以下代码排除重复文件

    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'
            }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-06-27
      • 1970-01-01
      • 2022-10-13
      • 1970-01-01
      • 2019-02-10
      • 2022-12-27
      • 2011-04-10
      相关资源
      最近更新 更多