Closed pascalAldavekollie closed 2 months ago
implementation ("com.google.android.gms:play-services-location:21.0.1") {
force = true;
}
This plugin is much smarter than that.
Did you ever wonder what those ext
params, that you're directed to add to your build.gradle
, are for?
There's one called googlePlayServicesLocationVersion
.
Look how the plugin's own build.gradle
uses that variable ext.googlePlayServicesLocationVersion
:
ext
vars.def playServicesLocationVersion = safeExtGet('playServicesLocationVersion', safeExtGet('googlePlayServicesLocationVersion', DEFAULT_PLAY_SERVICES_LOCATION_VERSION))
implementation "com.google.android.gms:play-services-location:$playServicesLocationVersion"
You don't need to provide hacks such as this:
implementation ("com.google.android.gms:play-services-location:21.0.1") {
force = true;
}
You have full control over the version of play-services-location
, that this plugin will use, in your app's root build.gradle
, via ext.googlePlayServicesLocationVersion
Of course, you may be using other plugins which are not as well-behaved as this one. Other plugins may have a hard-coded version in their build.gradle
, for example:
implementation "com.google.android.gms:play-services-location:19.0.0" // <--- UGLY! hard-coded version!
In which case, you'll need to manually align all other plugins to the same version. If you find some other plugin with a hard-coded version, RAISE AN ISSUE WITH THEM, and point them to my build.gradle
to show how to be a good plugin citizen and control the version using ext
vars.
You can easily determine which plugin is using which dependency version with the following command:
$ ./gradlew app:dependencies
The react-native-background-geolocation library is known to interact with Google Play Services, particularly through the ActivityRecognitionClient class for motion-detection features. The issue you're encountering might be due to a mismatch in the Google Play Services versions used by this library and other dependencies in your project.
To resolve this, you should ensure that all Google Play Services dependencies are using consistent and up-to-date versions. For example, the library might require a specific version of com.google.android.gms:play-services-location, so make sure that other Google Play Services dependencies in your build.gradle file are set to the same version.
You can also try forcing the specific version of the Google Play Services libraries by using the following in your build.gradle:
groovy Copy code implementation ("com.google.android.gms:play-services-location:21.0.1") { force = true; }