【发布时间】:2016-10-09 12:20:25
【问题描述】:
本周早些时候我遇到了一个问题。当我尝试进行 Android 发布构建时,它似乎显示以下错误--
错误:任务 ':app:transformClassesWithJarMergingForRelease' 执行失败。 com.android.build.api.transform.TransformException:java.util.zip.ZipException:重复条目:com/google/android/gms/internal/zzjm.class
我想知道我是如何得到这个错误的以及如何修复它。似乎问题出在 build.gradle 文件中。他们在这里--
应用级别 -
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.unknown.app"
minSdkVersion 13
targetSdkVersion 23
versionCode 20
versionName "2.34"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':BaseGameUtils')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.google.firebase:firebase-ads:9.0.2'
compile ('com.google.android.gms:play-services:9.0.2'){
exclude group: 'com.google.android.gms.play-services-ads'
}
}
apply plugin: 'com.google.gms.google-services'
这里是顶层——
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.2'
classpath 'com.google.gms:google-services:3.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
感谢所有帮助。我有这个问题有一段时间了。我在任何其他堆栈溢出问题中都找不到答案。再次感谢。
【问题讨论】:
-
也许这个链接对你有帮助>>stackoverflow.com/questions/33209631/…
-
我之前试过了,虽然没用。不过感谢您的帮助。
-
这个错误可能是因为你有两个具有相同类的相同库。我认为您必须从顶级 build.gradle 中删除 classpath 'com.google.gms:google-services:3.0.0'
-
好的。感谢您的帮助。
-
为什么你添加了两次
compile project(path: ':BaseGameUtils')和这里compile project(':BaseGameUtils')
标签: java android android-studio build.gradle