【发布时间】:2017-08-04 13:17:39
【问题描述】:
我正在从 Eclipse 导入我的项目,同时构建一个我发现以下错误的 APK。
错误:任务执行失败
com.android.build.api.transform.TransformException:java.util.zip.ZipException:重复条目:com/google/android/gms/plus/PlusOneButton$OnPlusOneClickListener.class
错误:任务 ':gruhini:transformClassesWithJarMergingForDebug' 执行失败。
com.android.build.api.transform.TransformException:java.util.zip.ZipException:重复条目:com/google/android/gms/games/Game.class
错误:任务 ':gruhini:transformClassesWithJarMergingForDebug' 执行失败。
com.android.build.api.transform.TransformException:java.util.zip.ZipException:重复条目:com/google/android/gms/auth/GoogleAuthException.class
错误:任务“:gruhini:processDebugGoogleServices”执行失败。
请通过更新 google-services 插件的版本(有关最新版本的信息可在 https://bintray.com/android/android-tools/com.google.gms.google-services/ 获得)或将 com.google.android.gms 的版本更新为 9.0.0 来解决版本冲突。
我的 build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "24.0.3"
useLibrary 'org.apache.http.legacy'
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/**'
}
defaultConfig {
applicationId "com.gruhini"
minSdkVersion 15
targetSdkVersion 24
versionCode 1
versionName "1.0"
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
dexOptions {
incremental true
preDexLibraries false
//javaMaxHeapSize "1G" // 2g should be also OK
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile project(':eclipseProject')
compile files('libs/activation.jar')
compile files('libs/additionnal.jar')
compile files('libs/google-play-services.jar')
compile files('libs/httpclient-4.1.jar')
compile files('libs/httpcore-4.1.jar')
compile files('libs/httpmime-4.1.jar')
compile files('libs/itextpdf-5.2.1.jar')
compile files('libs/mail.jar')
compile files('libs/mpandroidchartlibrary-1-7-4.jar')
compile 'com.android.support:support-v4:24.2.1'
testCompile 'junit:junit:4.12'
compile 'com.google.android.gms:play-services:10.2.0'
compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.android.support:design:24.2.1'
}
【问题讨论】:
-
为你的代码试试这个 android{ 配置 { all*.exclude group: 'com.android.support', module: 'support-annotations' } ]
-
您添加 google-play-services.jar 以及 com.google.android.gms:play-services:10.2.0
-
我试图隐藏编译文件的代码('libs/google-play-services.jar')。它仍然反映了同样的错误。
标签: android android-studio android-gradle-plugin build.gradle gradle-plugin