Expo React Native 应用程序在 Android 崩溃,但在 Expo Go 中运行

Expo React Native app crashes on Android but works in Expo Go

当我在 Expo Go 应用程序中预览我的应用程序时,一切正常,但是当我构建 android APK 时,一切正常,直到我尝试加载包含 MapView 的屏幕。 当我转到那个页面时,应用程序崩溃了,但没有告诉我出了什么问题

这是地图视图:

<MapView
    ref={map}
    style={styles.map}
    provider={PROVIDER_GOOGLE}
    initialRegion={location}
    pitchEnabled={false}
    userLocationUpdateInterval={3000}
    userLocationPriority="balanced"
    toolbarEnabled={false}
    tintColor="#00B4B4"
    customMapStyle={customMapStyle}
/>

顺便说一句,如果有任何日志,我不知道如何查看崩溃日志(我很想知道如何查看)

您需要添加 Google 地图 Api 键。在 expo go 中,expo 有自己的 Google Maps Api 密钥,但是当您构建自己的 apk 时,您需要从 expo 文档中添加 own.Check 这个:https://docs.expo.dev/versions/latest/sdk/map-view/#deploying-google-maps-to-an-android-standalone