Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build failure: duplicate entry: com/google/android/gms/auth/api/signin/zzc.class #301

Closed
ghost opened this issue Aug 16, 2017 · 16 comments
Closed

Comments

@ghost
Copy link

ghost commented Aug 16, 2017

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
> com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/android/gms/auth/api/signin/zzc.class

I'm getting this issue while trying to build into an detached Expo React Native app. Googling around, it seems this could be related to a mismatch of Google Play Services versions. Are you guys depending on Google Play Services. If so, what version. And could I potentially back-version that without issues?

@jkasten2
Copy link
Member

@ccuilla Correct, this SDK depends on Google Play Services. The OneSignal Android native SDK version 3.6.0 part of this SDK requires a minimum of 10.2.1 but will use up to 11.2.X if it is available on your system.

I recommend checking out the following troubleshooting section to resolve the version mismatches.
https://documentation.onesignal.com/docs/troubleshooting-android#section-error-all-gms-firesbase-libraries-must-use-the-exact-same-version-specification

@ghost
Copy link
Author

ghost commented Aug 16, 2017

Thanks. I'll check out that document.

@flieks
Copy link

flieks commented Sep 6, 2017

@ccuilla did you find the solution. I'm having the same error (also coming from Expo)

@ghost
Copy link
Author

ghost commented Sep 6, 2017

@flieks Yes, we simply back-versioned a couple things. I'll try to find the changes we made. This might be ugly, but it works for us. We actually change node_modules/react-native-onesignal/android/build.gradle as follows:

from:

    "compile 'com.google.android.gms:play-services-gcm:+'",
    "compile 'com.google.android.gms:play-services-analytics:+'",
    "compile 'com.google.android.gms:play-services-location:+'",

to:

    "compile 'com.google.android.gms:play-services-gcm:9.8.0'",
    "compile 'com.google.android.gms:play-services-analytics:9.8.0'",
    "compile 'com.google.android.gms:play-services-location:9.8.0'",

@ghost
Copy link
Author

ghost commented Sep 6, 2017

By the way we specifically do this:

const replace = require('replace-in-file'); // eslint-disable-line import/no-unresolved

const changedFiles = replace.sync({
  files: [
    'node_modules/react-native-onesignal/android/build.gradle',
  ],
  from: [
    "compile 'com.google.android.gms:play-services-gcm:+'",
    "compile 'com.google.android.gms:play-services-analytics:+'",
    "compile 'com.google.android.gms:play-services-location:+'",
  ],
  to: [
    "compile 'com.google.android.gms:play-services-gcm:9.8.0'",
    "compile 'com.google.android.gms:play-services-analytics:9.8.0'",
    "compile 'com.google.android.gms:play-services-location:9.8.0'",
  ],
});

@flieks
Copy link

flieks commented Sep 6, 2017

@ccuilla awesome. Where do you put that replace-in-file code? In gulp or some post build script?
I'm using Expo

@flieks
Copy link

flieks commented Sep 6, 2017

Seems to be working when replaced with your code. Thanks alot

@ghost
Copy link
Author

ghost commented Sep 6, 2017

Yeah, sorry we made a npm script like this in our package.json:

"back-version-one-signal-libraries": "node utilities/updateOneSignalGoogleServicesVersions.js",

Note this would be a PRE-build step.

@flieks
Copy link

flieks commented Sep 6, 2017

perfect, thanks

@slorber
Copy link
Contributor

slorber commented Nov 23, 2017

thanks a lot @ccuilla I can confirm this solution works fine with Expo SDK 23 ejected!

But not sure to understand why it actually works, because @jkasten2 said:

The OneSignal Android native SDK version 3.6.0 part of this SDK requires a minimum of 10.2.1 but will use up to 11.2.X if it is available on your system.

and 9.8.0 is not > 10.2.1

@jkasten2 would you please explain if this solution is good enough?

Also worth mentionning that it would be cool to have a clear integration path with this lib and
Expo after ejecting.

Currently, Expo offers an easy push system that works out of the box as long as they build the app themselves, but if you need to eject, you can't use anymore. So it's likely in the future more Expo users will be looking for alternative push notifications libraries like this one

@slorber
Copy link
Contributor

slorber commented Dec 11, 2017

@ccuilla I've found another more elegant solution to the same problem

In build.gradle add this before android { }. (there might be more appropriate places, at least it works fine for me and I'm not an Android expert)

configurations.all {
  resolutionStrategy.force 'com.google.android.gms:play-services-gcm:9.8.0'
  resolutionStrategy.force 'com.google.android.gms:play-services-analytics:9.8.0'
  resolutionStrategy.force 'com.google.android.gms:play-services-location:9.8.0'
}

or you can add as dependency:

  compile('com.google.android.gms:play-services-gcm:9.8.0') {
    force true
  }
  compile('com.google.android.gms:play-services-analytics:9.8.0') {
    force true
  }
  compile('com.google.android.gms:play-services-location:9.8.0') {
    force true
  }

@coolprobn
Copy link

Thanks @slorber , I was stuck on this issue since this morning.

@slorber
Copy link
Contributor

slorber commented Dec 11, 2017

np @coolprobn

btw for those coming from Expo It seems we often get dependency version problems on support libraries too.

This thread might help: https://forums.expo.io/t/detached-expo-on-android-sdk-build-tools-and-support-library-versions/5504

@voshawn
Copy link

voshawn commented Dec 15, 2017

I also ran into this issue, however, I also wanted to use react-native-background-geolocation, which depends on play-services >=11.2.0

Instead of rolling back the gcm, analytics, and location to 9.8.0, I was able to get all three (onesignal, expo, and background-geolocation to work together by upgrading all of expo's dependencies to 11.2.0:

  compile('com.google.android.gms:play-services-gcm:11.2.0') {
    force true
  }
  compile('com.google.android.gms:play-services-analytics:11.2.0') {
    force true
  }
  compile('com.google.android.gms:play-services-maps:11.2.0') {
    force true
  }
  compile('com.google.android.gms:play-services-auth:11.2.0') {
    force true
  }
  compile('com.google.android.gms:play-services-location:11.2.0') {
    force true
  }
  compile('com.google.android.gms:play-services-ads:11.2.0') {
    force true
  }
  compile('com.google.android.gms:play-services-fitness:11.2.0') {
    force true
  }
  compile('com.google.android.gms:play-services-wallet:11.2.0') {
    force true
  }

You can check what dependencies you need to upgrade by:
adding apply plugin: 'project-report' to the top of your app's build.gradle and running ./gradlew app:htmlDependencyReport

@jkasten2
Copy link
Member

You can also add the OneSignal-Gradle-Plugin which will automatically align the versions between these dependencies.

Feel free to reply if either of these two solutions do not work.

@prteekagni
Copy link

@jkasten2 none of them worked for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants