How to config expo MapView correctly?

25 views Asked by At

My android app is crashing due to MapView. Here is my code.

app.json

{
    "expo": {
        ...
        "android": {
            "config": {
                "googleMaps": {
                    "apiKey": "xxxxxxxxxxxxxxxxxxxxxxxxxxx"
                }
            }
        },
        ...
    }
}

App.js

import { StyleSheet, View } from 'react-native';
import MapView, { PROVIDER_GOOGLE } from 'react-native-maps';

export default function App() {
    return (
        <View style={styles.container}>
            <MapView
                style={{ width: '100%', height: '90%' }}
                region={{
                    latitude: 22.3700556,
                    longitude: 114.1535941,
                    latitudeDelta: 0.35,
                    longitudeDelta: 0.35,
                }}
                provider={PROVIDER_GOOGLE}></MapView>
        </View>
    );
}

const styles = StyleSheet.create({
    container: {
        flex: 1,
        backgroundColor: 'black',
        alignItems: 'center',
        justifyContent: 'center',
    },
});

When I test it with npx npm start, it works well. But it crashes with standalone app. I followed every steps on this page and below is my setting on google cloud.

0

There are 0 answers