android studio、gradle build 中的重复条目和 Zip 异常
Duplicate entry and Zip exception in android studio, gradle build
java.util.zip.ZipException:重复条目:com/google/gson/Gson$5.class
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
defaultConfig {
applicationId "com.hotel"
minSdkVersion 14
targetSdkVersion 21
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dexOptions {
javaMaxHeapSize "4g"
preDexLibraries false
}
}
dependencies {
compile('com.android.support:appcompat-v7:22.1.1') {
exclude group: 'com.google.android', module: 'support-v4'
exclude group: 'com.google.gson'
}
compile('com.facebook.android:facebook-android-sdk:4.1.0') {
exclude group: 'com.google.android', module: 'support-v4'
exclude group: 'com.google.gson'
}
compile('org.twitter4j:twitter4j-core:4.0.3') {
exclude group: 'com.google.android', module: 'support-v4'
exclude group: 'com.google.gson'
}
compile ('com.squareup.picasso:picasso:2.5.0') {
exclude group: 'com.google.android', module: 'support-v4'
exclude group: 'com.google.gson'
}
compile files('libs/Guest Helper.jar')
compile files('libs/OKSDK.jar')
compile files('libs/mobilekeys-android-api-deliverable-5.0.jar')
compile files('libs/mobilekeys-android-api-deliverable-soft-5.0.jar')
compile files('libs/FlurryAnalytics-5.3.0.jar')
compile files('libs/idconnect.jar')
compile files('libs/Guest.jar')
}
错误:
信息:Gradle任务[:app:assembleDebug]
:app:preBuild 最新
:app:preDebugBuild 最新版本
:应用程序:检查调试清单
:app:preReleaseBuild 最新版本
:app:prepareComAndroidSupportAppcompatV72211Library UP-TO-DATE
:app:prepareComAndroidSupportMultidex101Library 最新
:app:prepareComAndroidSupportSupportV42211Library UP-TO-DATE
:app:prepareComFacebookAndroidFacebookAndroidSdk410Library UP-TO-DATE
:app:prepareDebugDependencies
:app:compileDebugAidl 最新
:app:compileDebugRenderscript 最新
:app:generateDebugBuildConfig 最新
:app:generateDebugAssets 最新
:app:mergeDebugAssets 最新
:app:generateDebugResValues 最新
:app:generateDebugResources 最新
:app:mergeDebugResources 最新
:app:processDebugManifest 最新
:app:processDebugResources 最新
:app:generateDebugSources 最新
:app:processDebugJavaRes 最新
:app:compileDebugJava 最新
:app:compileDebugNdk 最新
:app:compileDebugSources 最新
:app:collectDebugMultiDexComponents 最新
:app:packageAllDebugClassesForMultiDex 失败
Error:Execution 任务“:app:packageAllDebugClassesForMultiDex”失败。 java.util.zip.ZipException:重复条目:com/google/gson/Gson$5.class
Information:BUILD失败
Information:Total 时间:8.085 秒
Information:1 错误
Information:0 警告
Information:See 在控制台中完成输出
我也遇到了同样的问题。将以下内容添加到 buildTypes
部分为我修复了它。
debug {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
我正在使用的库之一包含 google GSON 包,当我尝试 运行 构建时,它显示重复输入错误。然后我使用一个名为 JarSplice 的工具将两个库合并为一个,并在合并该工具时删除重复项并创建一个独立的 Jar 文件。
java.util.zip.ZipException:重复条目:com/google/gson/Gson$5.class
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
defaultConfig {
applicationId "com.hotel"
minSdkVersion 14
targetSdkVersion 21
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dexOptions {
javaMaxHeapSize "4g"
preDexLibraries false
}
}
dependencies {
compile('com.android.support:appcompat-v7:22.1.1') {
exclude group: 'com.google.android', module: 'support-v4'
exclude group: 'com.google.gson'
}
compile('com.facebook.android:facebook-android-sdk:4.1.0') {
exclude group: 'com.google.android', module: 'support-v4'
exclude group: 'com.google.gson'
}
compile('org.twitter4j:twitter4j-core:4.0.3') {
exclude group: 'com.google.android', module: 'support-v4'
exclude group: 'com.google.gson'
}
compile ('com.squareup.picasso:picasso:2.5.0') {
exclude group: 'com.google.android', module: 'support-v4'
exclude group: 'com.google.gson'
}
compile files('libs/Guest Helper.jar')
compile files('libs/OKSDK.jar')
compile files('libs/mobilekeys-android-api-deliverable-5.0.jar')
compile files('libs/mobilekeys-android-api-deliverable-soft-5.0.jar')
compile files('libs/FlurryAnalytics-5.3.0.jar')
compile files('libs/idconnect.jar')
compile files('libs/Guest.jar')
}
错误:
信息:Gradle任务[:app:assembleDebug] :app:preBuild 最新 :app:preDebugBuild 最新版本 :应用程序:检查调试清单 :app:preReleaseBuild 最新版本 :app:prepareComAndroidSupportAppcompatV72211Library UP-TO-DATE :app:prepareComAndroidSupportMultidex101Library 最新 :app:prepareComAndroidSupportSupportV42211Library UP-TO-DATE :app:prepareComFacebookAndroidFacebookAndroidSdk410Library UP-TO-DATE :app:prepareDebugDependencies :app:compileDebugAidl 最新 :app:compileDebugRenderscript 最新 :app:generateDebugBuildConfig 最新 :app:generateDebugAssets 最新 :app:mergeDebugAssets 最新 :app:generateDebugResValues 最新 :app:generateDebugResources 最新 :app:mergeDebugResources 最新 :app:processDebugManifest 最新 :app:processDebugResources 最新 :app:generateDebugSources 最新 :app:processDebugJavaRes 最新 :app:compileDebugJava 最新 :app:compileDebugNdk 最新 :app:compileDebugSources 最新 :app:collectDebugMultiDexComponents 最新 :app:packageAllDebugClassesForMultiDex 失败 Error:Execution 任务“:app:packageAllDebugClassesForMultiDex”失败。 java.util.zip.ZipException:重复条目:com/google/gson/Gson$5.class Information:BUILD失败 Information:Total 时间:8.085 秒 Information:1 错误 Information:0 警告 Information:See 在控制台中完成输出
我也遇到了同样的问题。将以下内容添加到 buildTypes
部分为我修复了它。
debug {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
我正在使用的库之一包含 google GSON 包,当我尝试 运行 构建时,它显示重复输入错误。然后我使用一个名为 JarSplice 的工具将两个库合并为一个,并在合并该工具时删除重复项并创建一个独立的 Jar 文件。