Reputation: 107
>Error:Execution failed for task ':app:transformClassesWithJarMergingForRelease'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/android/gms/common/api/zzf.class
Getting this error whenever i try to generate signed apk..
Have tried cleaning code Have tried excluding packages
Build.Gradle(app)
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion "26.0.1"
defaultConfig {
applicationId "com.app.app"
minSdkVersion 16
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner
"android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
multiDexEnabled true
manifestPlaceholders = [onesignal_app_id: "",
// Project number pulled from dashboard, local
value is ignored.
onesignal_google_project_number: ""]
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
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 'cn.pedant.sweetalert:library:1.3'
compile 'com.onesignal:OneSignal:[3.6.2, 3.99.99]'
compile 'com.yalantis:contextmenu:1.0.7'
compile 'com.crystal:crystalrangeseekbar:1.1.1'
compile 'com.github.mzelzoghbi:zgallery:0.3'
compile 'com.rengwuxian.materialedittext:library:2.1.4'
compile 'com.yalantis:flipviewpager:1.0.0'
compile 'com.android.support:appcompat-v7:26.+'
compile 'com.android.support:design:26.+'
compile 'com.android.support:support-vector-drawable:26.+'
compile 'com.android.support:support-v4:26.0.0-alpha1'
compile 'com.squareup.picasso:picasso:2.3.2'
compile 'com.nineoldandroids:library:2.4.0'
compile 'com.google.zxing:core:3.2.1'
compile 'com.google.firebase:firebase-core:11.4.2'
testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
Upvotes: 1
Views: 3148
Reputation: 27958
You could add a task to find the duplicates
task findDuplicates {
doLast {
Map<String, List<File>> map = [:]
Set<File> jars = configurations.compile.matching {
include '**/*.jar'
}.files
jars.each { File jarFile ->
zipTree(jarFile).visit { FileVisitDetails fvd ->
String path = fvd.relativePath.pathString
List<File> matches = map[path] ?: []
matches << jarFile
map[path] = matches
}
}
map.each { String path, List<File> matches ->
if (matches.size() > 1) {
println "Found $path in $matches"
}
}
}
}
Then run gradle findDuplicates
from command line
Upvotes: 0
Reputation: 7936
Change support library versions to 26.1.0 like below:
compile 'com.android.support:appcompat-v7:26.1.0'
compile 'com.android.support:design:26.1.0'
compile 'com.android.support:support-vector-drawable:26.1.0'
compile 'com.android.support:support-v4:26.1.0'
Currently, 26.+
uses 26.1.0
and you are trying to use 26.0.0-alpha1
at the same time and it causes duplication.
UPDATE: Update Your project's main gradle like below, add subprojects {...} part to force to use same version of support library.
allprojects {
repositories {
//maven jcenter etc.
}
subprojects {
project.configurations.all {
resolutionStrategy.eachDependency { details ->
if (details.requested.group == 'com.android.support'
&& !details.requested.name.contains('multidex') ) {
details.useVersion "26.1.0"
}
}
}
}
}
Upvotes: 1
Reputation: 3393
Edit: Only removing this line will work:
compile 'com.android.support:support-v4:26.0.0-alpha1'
You have this class duplicated, probably because two (or more) of your libraries are adding the same dependencies.
The first step you must take is to identify which one is interfering. You can try running the dependencies
task in Gradle, and see what dependencies (or their children) are clashing.
The seconds step will be to tell the Gradle script to exclude that dependency
Upvotes: 0