react-native-maps: Android Device Only - Error while updating property 'showsUserLocation' of a view managed by: AIRMap

Summary

Hello,

I’m encountering an issue while using the latest versions of react-native-maps and react-native. Below, you’ll find a screenshot of my android/build.gradle file for reference: image

Despite my efforts, I haven’t been able to resolve this problem. I’ve explored various solutions in the issues section, but none of them seem to work for me.

I’ve attempted the following in my android/app/build.gradle file: Adding implementation "com.google.android.gms:play-services-location:20.0.0" or implementation "com.google.android.gms:play-services-location:21.0.1"

Additionally, I experimented with different playServicesVersion values in android/build.gradle, including:

playServicesVersion = "18.0.0"
playServicesVersion = "20.0.0"
playServicesVersion = "21.0.1"

Also attempted using the beta version of react-native-maps, and it worked but it caused issues with my existing map code and contained some bugs, such as lacking support for animated in .fitToCoordinates."

Reproducible sample code

<MapView
      ref={ref}
      provider={PROVIDER_GOOGLE}
      style={{flex: 1}}
      showsUserLocation={true} // show user's current location
      showsMyLocationButton={true} // show button to center on user's location
      initialRegion={{
        latitude: 6.1897,
        longitude: 102.1573,
        latitudeDelta: 0.0922,
        longitudeDelta: 0.0421,
      }}
      {...props.mapProps}
      // region={{
      //   latitude: 6.155625340041729,
      //   latitudeDelta: 0.02002058218781322,
      //   longitude: 102.1837292611599,
      //   longitudeDelta: 0.012100785970673655,
      // }}
      customMapStyle={mapOptions.customMapStyle}>
      {props.children}
    </MapView>

Steps to reproduce

Just run ./gradlew clean and yarn react-native run-android

Expected result

It should be working fine on showsUserLocation={true}. But if showsUserLocation={false} is ok.

Actual result

WhatsApp Image 2023-09-09 at 01 15 16

React Native Maps Version

^1.7.1

What platforms are you seeing the problem on?

Android

React Native Version

0.72.4

What version of Expo are you using?

Not using Expo

Device(s)

SAMSUNG GALAXY S20 FE (ANDROID 13)

Additional information

Please assist me in resolving this issue; I am currently stuck at this point. Thanks!

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 8
  • Comments: 16

Commits related to this issue

Most upvoted comments

Facing the same issue after upgrading react-native from 0.71.10 to 0.72.4.

EDIT: Created a patch file with the patch-package npm package.

If you need to patch your package here are the steps:

  1. Go to the node_modules/react-native-maps/android/build.gradle
  2. update the file from
implementation "com.google.android.gms:play-services-location:20.0.0"

to

implementation "com.google.android.gms:play-services-location:21.0.0"
  1. Create a patch file
npx patch-package react-native-maps --include "android/build.gradle"
  1. Then install patch package as a project dependency with
yarn add patch-package
  1. Add the following to your package.json script section:
"postinstall": "patch-package"

The map is functioning correctly after I made changes to the dependency in the node_modules/react-native-maps/android/build.gradle file as follows:

+ classpath("com.android.tools.build:gradle:7.1.1")
+ implementation "com.google.android.gms:play-services-location:21.0.1"

But please assist me in discovering a better and proper solution instead of this.

Still relevant, working through this issue with a react-native app now

can be reproduced! still relevant and using RN v0.72.10

Hm I cant tell exactly. Maybe you could just install the package as the first step and then go on with all other steps.

But if you have the patchfile and remove node modules and make a fresh install everything should be fine 👌

Now it working fine, maybe that was my mistake. I placed “postinstall”: “patch-package” in the wrong location. Thanks.