Solvedreact native onesignal 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.

Description:

I installed react-native-onesignal as per the documentation. It is working just fine on iOS, but it is causing biuld issues on the android side relating to Google Play service dependencies. It does seem to go through if I downgrade to google-services from 4.2.0 to 4.1.0, but unfortunately, downgrading breaks several of my other dependencies.

I have seen this issue logged in a few places on the android side, which leads me to believe that there is an issue with the latest version of the android SDK that is supported by this react-native library:

OneSignal/OneSignal-Android-SDK#894
https://stackoverflow.com/questions/59128152/error-in-project-app-a-resolved-google-play-services-library-dependency-depen

Here is the error I am receiving:

> 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.3 -> com.google.android.gms:play-services-location@[10.2.1, 16.0.99], b
  ut play-services-location version was 15.0.1.
  
  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:play-services-location@{strictly 15.0.1}
  -- Project 'app' depends onto com.onesignal:OneSignal@{strictly 3.12.3}
  -- Project 'app' depends on project 'react' which depends onto com.onesignal:OneSignal@3.12.3

Environment

  1. react-native-onesignal version 3.6.0
  2. yarn and react-native link

Steps to Reproduce Issue:

  1. Install the OneSignal SDK using yarn into the project
  2. Use google-services version 4.2.0 and the onesignal-gradle-plugin to the gradle buildscript:
buildscript {
  ...
  repositories {
    ...
    maven {
            url 'https://plugins.gradle.org/m2/'
        }
  }
  dependencies {
    ...
    classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:[0.12.1, 0.99.99]'
    classpath 'com.google.gms:google-services:4.2.0'
  }
}
  1. Apply the gradle plugin after the buildscript
apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'
  1. Attempt to build start the android app
react-native run-android

Anything else:

18 Answers

✔️Accepted Answer

Try to declare onesignal-gradle-plugin before google-services in android\app\build.gradle:

apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'
apply plugin: 'com.google.gms.google-services'

More Issues: