React 原生地图可以在 expo go 中工作,但不能通过 expo 在 APK 中工作

问题描述 投票:0回答:1

我在反应本机 apk 时遇到问题。 如果我使用 expo go,我在地图中的代码就可以工作。我可以在地图中看到我当前的位置和其他功能。所以最近,我通过 expo 创建了一个 APK 应用程序,EAS 构建。 APK 工作正常,因为我可以更改用户的密码,但在 APK 中,特别是在地图屏幕中,地图不会显示。

这是我尝试过的:

  1. https://docs.expo.dev/versions/latest/sdk/map-view/#add-the-api-key-to-your-project
  2. 我在地图中的代码
 {location && (
        <MapView
          // onMapReady={() => {
          //   orderInformation.forEach((customer) => {
          //     handleMarkerPress(customer);
          //   });
          // }}
          ref={mapRef}
          provider={PROVIDER_GOOGLE}
          mapType="hybrid"
          style={styles.map}
          initialRegion={{
            latitude: location.coords.latitude,
            longitude: location.coords.longitude,
            latitudeDelta: 0.01,
            longitudeDelta: 0.01,
          }}

  1. 我的应用程序.json
 "android": {
      "adaptiveIcon": {
        "foregroundImage": "./assets/adaptive-icon.png",
        "backgroundColor": "#FFFFFF"
      },
      "config":{

        "googleMaps": {
          "apiKey": "mykey"
        }
      },
      "permissions": [
        "ACCESS_FINE_LOCATION",
        "ACCESS_COARSE_LOCATION",
        "ACCESS_BACKGROUND_LOCATION",
        "CAMERA_ROLL",
        "READ_EXTERNAL_STORAGE",
        "WRITE_EXTERNAL_STORAGE"
      ],
 "package": "com.xxxxxxxx.com"
    },

我什至编辑我的 API 密钥以添加来自 Expo 凭证的 SHA-1 证书指纹。 谢谢你。

react-native expo apk
1个回答
0
投票

你找到解决方案了吗,因为我也遇到了同样的问题?

© www.soinside.com 2019 - 2024. All rights reserved.