Reputation: 7209
java.util.zip.ZipException: duplicate entry: 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')
}
Error :
Information:Gradle tasks [:app:assembleDebug] :app:preBuild UP-TO-DATE :app:preDebugBuild UP-TO-DATE :app:checkDebugManifest :app:preReleaseBuild UP-TO-DATE :app:prepareComAndroidSupportAppcompatV72211Library UP-TO-DATE :app:prepareComAndroidSupportMultidex101Library UP-TO-DATE :app:prepareComAndroidSupportSupportV42211Library UP-TO-DATE :app:prepareComFacebookAndroidFacebookAndroidSdk410Library UP-TO-DATE :app:prepareDebugDependencies :app:compileDebugAidl UP-TO-DATE :app:compileDebugRenderscript UP-TO-DATE :app:generateDebugBuildConfig UP-TO-DATE :app:generateDebugAssets UP-TO-DATE :app:mergeDebugAssets UP-TO-DATE :app:generateDebugResValues UP-TO-DATE :app:generateDebugResources UP-TO-DATE :app:mergeDebugResources UP-TO-DATE :app:processDebugManifest UP-TO-DATE :app:processDebugResources UP-TO-DATE :app:generateDebugSources UP-TO-DATE :app:processDebugJavaRes UP-TO-DATE :app:compileDebugJava UP-TO-DATE :app:compileDebugNdk UP-TO-DATE :app:compileDebugSources UP-TO-DATE :app:collectDebugMultiDexComponents UP-TO-DATE :app:packageAllDebugClassesForMultiDex FAILED Error:Execution failed for task ':app:packageAllDebugClassesForMultiDex'. java.util.zip.ZipException: duplicate entry: com/google/gson/Gson$5.class Information:BUILD FAILED Information:Total time: 8.085 secs Information:1 error Information:0 warnings Information:See complete output in console
Upvotes: 3
Views: 3106
Reputation: 7209
One of the libraries i am using was containing the google GSON package and when i am trying to run the build , it shows me error of duplicate entry. Then i used a tool called JarSplice to merge both of the libraries into one, and while merging this tool remove the duplicate items and create a standalone Jar file.
Upvotes: 1
Reputation: 1
I also had the same problem. Adding the following to the buildTypes
section fixed it for me.
debug {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
Upvotes: 0