react-native-maps: error: package com.google.android.gms.location does not exist
Bug
Using the latest package from github, and after following all install instructions (having previous versions working perfectly), I get an error: package com.google.android.gms.location does not exist.
Build fails on line 17 of AirMapManager.java.
This was added in the recent commit “Improved user location on Android (#2993)”
Here is an extract from my app/build.gradle
implementation(project(':react-native-maps')){
exclude group: 'com.google.android.gms', module: 'play-services-base'
exclude group: 'com.google.android.gms', module: 'play-services-maps'
}
implementation 'com.google.android.gms:play-services-base:17.1.0'
implementation 'com.google.android.gms:play-services-maps:17.0.0'
implementation 'com.google.android.gms:play-services-location:17.0.0'
Library version: next
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 8
- Comments: 15 (1 by maintainers)
Adding
implementation 'com.google.android.gms:play-services-location:16.0.0'To the android-react-native-maps.gradle file removes the no definitions for me, but then introduces new errors around setUserLocationPriority, setUserLocationUpdateInterval and setUserLocationFastestInterval not being defined in AirMapManager.java
In my case, I had to replace
playServicesVersion = "17.0.0"withplayServicesVersion = "18.1.0"in the android build.gradle fileIn my case I changed the
playServicesVersionvariable togooglePlayServicesVersion= “17.0.0”.using:
So I have submitted a new PR fixing my previous PR 😉
It seems like some of the code in the PR somehow got lost in the merge process, like the dependency for play-service-location and several of my added methods to AirMapView.java. I do not know why, but now at least they are there in the new PR (3320), and they work as far as I can tell.
FIX
I fix this solution by removing bellow existing maps package from my node_modules folder
"react-native-maps": "git+https://git@github.com/react-native-community/react-native-maps.git"and re-install it with this command
yarn add react-native-maps -Eornpm install react-native-maps --save-exactIt didn’t work for me 😕
I needed fix that quicky so I added
implementation 'com.google.android.gms:play-services-location:16.+'in the react-native-library on this file node_modules/react-native-maps/lib/android/build.gradle and I fix one of the bug and for the another one Comment from line 165 to line 175 in this path node_modules/react-native-maps/lib/android/src/main/java/com/airbnb/android/react/maps/AirMapManager.javasomething like that `@ReactProp(name = “userLocationPriority”) public void setUserLocationPriority(AirMapView view, @Nullable String accuracy) { view.setUserLocationPriority(MY_LOCATION_PRIORITY.get(accuracy)); }
@ReactProp(name = “userLocationUpdateInterval”, defaultInt = 5000) public void setUserLocationUpdateInterval(AirMapView view, int updateInterval) { view.setUserLocationUpdateInterval(updateInterval); }
@ReactProp(name = “userLocationFastestInterval”, defaultInt = 5000) public void setUserLocationFastestInterval(AirMapView view, int fastestInterval) { view.setUserLocationFastestInterval(fastestInterval); }`
I know there are 3 properties that are not working but I needed fix it for my project