反应本机地图 - android 上的白色地图问题

react native maps - white map issue on android

我正在尝试 运行 我的 React 本机应用 react-native-maps. I am getting the white map with red border issue. I am sure the answer to that for me is the bottom comment here。但是当我在 xxx/android/app/src/main/java/com/xxx/MainApplication.java 中的代码中实现它时,我只得到这个错误:

error: package com.airbnb.android.react.maps does not exist

如何将该包添加到我的 react-native 应用程序的 android 版本中?

android/settings.gradle 具有从 projects/packages 到 node_modules 中相应文件夹的映射。

在 react-native-maps 文档中它说这应该在 android/settings.gradle:

include ':react-native-maps'
project(':react-native-maps').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-maps/android')

但是观察我的node_modules/react-native-maps文件夹,发现android文件夹的路径和上面的不一样,有lib,然后是android。所以我改成了这个(在"android"之前添加"lib"):

include ':react-native-maps'
project(':react-native-maps').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-maps/lib/android')

然后在 android studio 中清理并重建项目,然后就可以了。