error trying to use Polyline of MapView (Google maps)

I’m showing a google map with expo in React native (I’m using Expo), but when I try to draw a line with polyline, I get this this error:

Error while updating property ‘lineCap’ of a view managed by: AIRMapPolyline
null
Attempt to invoke virtual method ‘void com.google.android.gms.maps.model…u.g(java.util.List) on a null object reference

This is the code:

           <MapView
                style={styles.map}
                initialRegion={{
                    latitude: initialLocation.latitude,
                    longitude: initialLocation.longitude,
                    latitudeDelta: 0.01,
                    longitudeDelta: 0.01
                }}
            >
                <Circle
                    center={currentLocation.coords}
                    radius={30}
                    strokeColor='rgba(158, 158, 255, 1.0)'
                    fillColor='rgba(0, 0, 255, 0.3)'
                />
                {drawLine && (
                    <MapView.Polyline
                        coordinates={locations.map(loc => {
                            return {
                                latitude: loc.coords.latitude,
                                longitude: loc.coords.longitude
                            };
                        })}
                        strokeColor='red'
                        strokeWidth={1}
                    />
                )}
            </MapView>

The map draws ok, the circle shows ok, but when I try to draw a line, it throws that awful error.

The array of objects sent as coordinates is ok

The github is GitHub - rafaelsoteldosilva/maptest

You press Start Moving, then press Start Recording, wait a couple of seconds and press Draw, bum!, there’s the error

Rafael

Hey @rafaelsoteldo, we have a github issue currently focusing on the Polyline Android issue. We’ll focus our efforts there!

Cheers,
Adam

Thank you for your answer. I follow the issue…

I have the same issue. Can’t upgrade SDK because of this

It works with EOS BUILD if you set the version react-native-maps version to 0.29.2 as the issue is fixed in that version.

Just run this in your project folder to get the right version:
npm install react-native-maps@0.29.2

And you package.json and package-lock.json should be uploaded like below.

package.json:

"dependencies":
    "react-native-maps": "^0.29.2",

package-lock.json:

    "react-native-maps": {
      "version": "0.29.2",
      "resolved": "https://registry.npmjs.org/react-native-maps/-/react-native-maps-0.29.2.tgz",
    },

But please note it will still not work in your development environment. Only in production. So your app will still crash in development.