I found this article really helpful for solving play-services dependency issues I had while upgrading my demo app to use react-native-maps
How to solve Google Play Services version collision in gradle dependences
As I've always said, your app's build.gradle should have the final word on specific version of play-services dependencies.
Eg: In your app/build.gradle:
before
dependencies {
compile project(‘:react-native-fcm’)
compile ‘com.google.firebase:firebase-core:10.0.1’
compile project(‘:react-native-fs’)
compile project(‘:react-native-camera’)
compile project(‘:react-native-material-kit’)
compile project(‘:react-native-vector-icons’)
compile project(‘:react-native-maps’)
compile project(‘:react-native-i18n’)
compile project(‘:react-native-device-info’)
compile project(‘:react-native-config’)
compile fileTree(dir: “libs”, include: [“*.jar”])
compile “com.android.support:appcompat-v7:23.0.1”
compile “com.facebook.react:react-native:+” // From node_modules
}
after
dependencies {
compile project(‘:react-native-fcm’)
compile ‘com.google.firebase:firebase-core:10.0.1’
compile project(‘:react-native-fs’)
compile project(‘:react-native-camera’)
compile project(‘:react-native-material-kit’)
compile project(‘:react-native-vector-icons’)
compile(project(':react-native-maps')){
exclude group: 'com.google.android.gms', module: 'play-services-base'
exclude group: 'com.google.android.gms', module: 'play-services-maps'
}
compile project(‘:react-native-i18n’)
compile(project(':react-native-device-info')) {
exclude group: 'com.google.android.gms'
}
compile project(‘:react-native-config’)
compile fileTree(dir: “libs”, include: [“*.jar”])
compile “com.android.support:appcompat-v7:23.0.1”
compile “com.facebook.react:react-native:+” // From node_modules
// Now force load *YOUR* desired versions:
compile ("com.google.android.gms:play-services-base:10.2.0") {
force = true;
}
compile ("com.google.android.gms:play-services-maps:10.2.0") {
force = true;
}
}
For anyone else struggling with this, here's the app/build.gradle dependencies section I ended up with:
dependencies {
compile(project(':react-native-maps')) {
exclude group: 'com.google.android.gms'
}
compile project(':react-native-background-geolocation')
compile(name: 'tslocationmanager', ext: 'aar')
// ... more packages in between
compile ("com.google.android.gms:play-services-base:+") { // the plus allows you to use the latest version
force = true;
}
compile ("com.google.android.gms:play-services-maps:+") {
force = true;
}
}
Also if unexpected errors still show up try cd android/ && ./gradlew clean
You know that Mauron85 project comes from a fork of my original open-source project for Cordova from about 3 years ago?
I figured something similar, but did not know the exact details.
This is my working build.gradle, at least compiled
apply plugin: 'com.android.application'
....
dependencies {
compile(project(':react-native-device-info')) {
exclude group: 'com.google.android.gms'
}
compile project(':react-native-onesignal')
compile project(':react-native-background-geolocation')
compile(name: 'tslocationmanager', ext: 'aar')
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:customtabs:25.3.1'
compile 'com.android.support:multidex:1.0.1'
compile 'com.google.android.gms:play-services:11.0.2'
compile('host.exp.exponent:expoview:19.0.0@aar') {
exclude group: 'com.facebook.android', module: 'facebook-android-sdk'
exclude group: 'com.facebook.android', module: 'audience-network-sdk'
exclude group: 'io.nlopez.smartlocation', module: 'library'
transitive = true;
}
compile ('com.facebook.android:facebook-android-sdk:4.7.0') {
exclude module: 'bolts-android'
}
compile('com.facebook.android:audience-network-sdk:4.19.0') {
exclude module: 'play-services-ads'
}
compile('io.nlopez.smartlocation:library:3.2.11') {
transitive = false
}
...
}
This works for me as well, after coming back and forcing sdk to 23 for client compatibility reasons.
compile 'com.google.android.gms:play-services:+'
compile 'com.google.firebase:firebase-core:+'
Firebase and play-services require the same version number. As long as
they’re the same version, all is good.
On Thu, Oct 19, 2017 at 1:55 AM Penn Su notifications@github.com wrote:
This works for me as well, after coming back and forcing sdk to 23 for
client compatibility reasons.compile 'com.google.android.gms:play-services:+'
compile 'com.google.firebase:firebase-core:+'—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/transistorsoft/react-native-background-geolocation/issues/229#issuecomment-337807106,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAA6l410tsmE0Lx6JFR9x4do3H5xv1ILks5stuRJgaJpZM4Mfzm2
.>
Snet form Gmail Mobile
Thanks @greyvugrin
Although it still crashed for me until I added these lines also:
compile ("com.google.android.gms:play-services-gcm:+") {
force = true;
}
compile ("com.google.android.gms:play-services-location:+") {
force = true;
}
@lfkwtz Don't use version +. Use a specific version.
See here for latest version (11.8.0).
@christocracy okay. that works and i'll do that.
this is working for me -- anything look wrong?
dependencies {
compile project(':react-native-image-crop-picker')
compile project(':react-native-text-input-mask')
compile project(':react-native-config')
compile project(':react-native-vector-icons')
compile project(':react-native-background-geolocation')
compile project(':react-native-sentry')
compile fileTree(dir: "libs", include: ["*.jar"])
compile "com.android.support:appcompat-v7:23.0.1"
compile "com.facebook.react:react-native:+" // From node_modules
compile(name: 'tslocationmanager', ext: 'aar')
compile(project(':react-native-maps')) {
exclude group: 'com.google.android.gms'
}
compile 'com.android.support:multidex:1.0.1'
compile ("com.google.android.gms:play-services-base:11.8.0") {
force = true;
}
compile ("com.google.android.gms:play-services-maps:11.8.0") {
force = true;
}
compile ("com.google.android.gms:play-services-gcm:11.8.0") {
force = true;
}
compile ("com.google.android.gms:play-services-location:11.8.0") {
force = true;
}
}
You should probably open :react-native-background-geolocation and exclude group: 'com.google.android.gms' as well, since it's going to import 11.6.0.
Confirmed Fix: Add google() inside the allprojects.repositories, above mavenLocal
NOTE: The directions in this issue should be ignored now that react-native supports providing gradle config parameters in one's android/build.gradle. Most popular plugins are now aware of these config params and will align their dependencies accordingly, including this one.
buildscript {
ext {
buildToolsVersion = "27.0.3"
minSdkVersion = 16
compileSdkVersion = 27
targetSdkVersion = 26
supportLibVersion = "27.1.1"
googlePlayServicesVersion = "16.0.0"
I also have the same problem, how do i include ang exclude command to a implementation pattern?
implementation project(':react-native-vector-icons')
implementation project(':react-native-maps')
implementation project(':react-native-firebase')
implementation project(':react-native-geolocation-service')
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
implementation "com.facebook.react:react-native:+" // From node_modules
implementation "com.google.android.gms:play-services-base:16.0.1"
implementation "com.google.firebase:firebase-core:16.0.6"
implementation "com.google.firebase:firebase-auth:16.1.0"
implementation "com.google.firebase:firebase-firestore:17.1.5"
See Android Setup. Provide googlePlayServicesLocationVersion (Assuming you’re using latest plugin version, you didn’t specify which version you’re using)
https://github.com/transistorsoft/react-native-background-geolocation/blob/master/help/INSTALL-ANDROID.md#open_file_folder-androidbuildgradle
There is no longer a need to manually import google dependencies like you’re doing. That is the purpose of gradle config properties.
Btw, do not follow the directions in this issue anymore. This issue is 2 years old and obsolete.
Most helpful comment
For anyone else struggling with this, here's the
app/build.gradledependencies section I ended up with:Also if unexpected errors still show up try
cd android/ && ./gradlew clean