1

I think onesignal is making a conflict here>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' 

3 Answers 3

1

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" } } } } } 
Sign up to request clarification or add additional context in comments.

2 Comments

@VivekRaj then you need to check other library dependencies if any version conflicts exists. Or check my updated answer
still no luck :(
0

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

5 Comments

Try running the Gradle's dependencies task please, and post the output on your question
Still no luck :(
Running this task will not solve your problem, it will hint you in the Gradle Output where the problem is to fix it. When you have the output of running this task, please post it here editing your question, if you can't figure out yourself where the problem is
ohh sorry ...can you please tell me how to do that ?
run ./gradlew dependencies it will give you the dependecies' tree of your project. you can use ./gradlew app:dependencies to check just your module
0

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.