React-native-onesignal: Dependency problem after added react-native-firebase

Created on 12 Mar 2020  路  11Comments  路  Source: OneSignal/react-native-onesignal

Description:

My react-native application, using react-native-onesignal was working perfectly but due to iOS problems I had to change "firebase" to "react-native-firebase". After added classpath("com.google.gms:google-services:4.3.3") to android/build.gradle and apply plugin: "com.google.gms.google-services" to android/app/build.gradle OneSignal start conflict dependencies, as the following message describes:

In project 'app' a resolved Google Play services library dependency depends on another at an exact version (e.g. "[10.2.1, 16.0.99]", but isn't being resolved to that version. Behavior exhibited by the library will be unknown.
Dependency failing: com.onesignal:OneSignal:3.12.7 -> com.google.android.gms:play-services-location@[10.2.1, 16.0.99], but play-services-location version was 16.0.0.
The following dependencies are project dependencies that are direct or have transitive
dependencies that lead to the artifact with the issue.
-- Project 'app' depends onto com.onesignal:OneSignal@{strictly 3.12.7}
-- Project 'app' depends on project 'react' which depends onto com.onesignal:[email protected]
-- Project 'app' depends onto com.google.android.gms:play-services-location@{strictly 16.0.0}

Environment

react-native-onesignal:^3.6.0. Already tried with react-native-onesignal: ^3.6.5
All dependencies were added by yarn

yarn add react-native-onesignal
yarn add @react-native-firebase/app
yarn add @react-native-firebase/auth
yarn add @react-native-firebase/database

Steps to Reproduce Issue:

As my application is an existing application, I just added the firebase dependencies. I guess that to reproduce this error, from scratch, just adding react-native-onesignal and than adding react-native-firebase dependencies and try to run might cause this dependency problem.

Anything else:

Dependency resolved to an incompatible version: Dependency(fromArtifactVersion=ArtifactVersion(groupId=com.onesignal, artifactId=OneSignal, version=3.12.7), toArtifact=Artifact(groupId=com.google.android.gms, artifactId=play-services-location), toArtifactVersionString=[10.2.1, 16.0.99])

Compatibility Issue Help Wanted

Most helpful comment

@mostafaebrahimi These dependency issue should be resolved after adding the onesignal-gradle-plugin to your project. Please follow the Adding the Gradle Plugin section in the OneSignal React Native setup guide.

All 11 comments

same problem here!
any solution?

@mostafaebrahimi These dependency issue should be resolved after adding the onesignal-gradle-plugin to your project. Please follow the Adding the Gradle Plugin section in the OneSignal React Native setup guide.

I'm experiencing this issue even with the gradle plugin added as described. @jkasten2

Howdy y'all,
Based on previous responses, this is likely a dependency management issue that needs to be added to the Gradle Plugin. Thanks for your patience.

If anyone figures out which specific version ranges/combinations fix the issue, please let us know!

@dancherb ,
Can you please include how you added the Gradle plugin to your project?

I'm fix this issue changing the version from classpath("com.google.gms:google-services:4.3.3") to classpath("com.google.gms:google-services:4.2.0")

@itsmicaio ,
Sorry, I mean the OneSignal Gradle Plugin.

@rgomezp My build.gradle files are in different folders for my React Native project.

I've added the following to my android/build.gradle:

dependencies {
        classpath("com.android.tools.build:gradle:3.5.2")
        classpath('com.google.gms:google-services:4.3.3')
        classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:[0.12.6, 0.99.99]' <--- added this

allprojects {
    repositories {
        mavenLocal()
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url("$rootDir/../node_modules/react-native/android")
        }
        maven {
            // Android JSC is installed from npm
            url("$rootDir/../node_modules/jsc-android/dist")
        }

        google()
        jcenter()
        maven { url 'https://www.jitpack.io' }
        maven { url 'https://plugins.gradle.org/m2/' } <-- added this
    }
}

In my android/app/build.gradle I've added the following:

apply plugin: "com.android.application"
apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin' <--- added this
apply plugin: 'com.google.gms.google-services'

Which ends up in:

Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'.
> In project 'app' a resolved Google Play services library dependency depends on another at an exact version (e.g. "[10.2.
  1, 16.0.99]", but isn't being resolved to that version. Behavior exhibited by the library will be unknown.

  Dependency failing: com.onesignal:OneSignal:3.13.2 -> com.google.android.gms:play-services-location@[10.2.1, 16.0.99], b
  ut play-services-location version was 16.0.0.

  The following dependencies are project dependencies that are direct or have transitive dependencies that lead to the art
  ifact with the issue.
  -- Project 'app' depends onto com.google.android.gms:[email protected]
  -- Project 'app' depends onto com.google.android.gms:play-services-location@{strictly 16.0.0}
  -- Project 'app' depends onto com.onesignal:OneSignal@{strictly 3.13.2}
  -- Project 'app' depends on project 'react' which depends onto com.onesignal:[email protected]

Howdy,
Thanks for your patience. We'll take a look at whether there is a possible conflict here and whether it can be fixed easily.

@chrisd1997
Can you make sure you have com.google.gms.google-services at the very bottom of your android/app/build.gradle below the dependencies {} section?
apply plugin: 'com.google.gms.google-services'

You can also try adding googleServices { disableVersionCheck = true } to your build.gradle but it shouldn't be required as onesignal-gradle-plugin should be doing this already.
https://github.com/OneSignal/OneSignal-Gradle-Plugin/issues/37#issuecomment-391983620

Closing due to no response

Was this page helpful?
0 / 5 - 0 ratings