我正在使用react-native-maps在我的页面中显示Mapview,不幸的是它在Iphone中可以正常运行,但在android中却没有显示Mapview,它只显示了logo,是的,我遵循了文档中提到的所有配置步骤。 / p>
使用以下命令安装react-native-maps
npm install react-native-maps --save
链接图:
react-native link react-native-maps
检查android/settings.gradle
中的react-native-maps项目:
include ':react-native-maps'
project(':react-native-maps').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-maps/lib/android')
在android/app/build.gradle
中检查应用程序的依赖性:
dependencies {
...
compile project(':react-native-maps')
...
}
选中android/build.gradle
:
ext {
buildToolsVersion = "27.0.3"
minSdkVersion = 16
compileSdkVersion = 27
targetSdkVersion = 26
supportLibVersion = "27.1.1"
googlePlayServicesVersion = "11.8.0"
androidMapsUtilsVersion = "0.5+"
}
在android/app/src/main/AndroidManifest.xml
中指定您的Google Maps API密钥:
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="MY API KEY"/>
这是我的package.json
文件依赖项
"dependencies": {
"accordion-collapse-react-native": "^0.1.6",
"buffer": "^5.2.1",
"react": "16.6.0-alpha.8af6728",
"react-native": "0.57.3",
"react-native-calendars": "^1.21.0",
"react-native-check-box": "^2.1.5",
"react-native-chooser": "^1.7.0",
"react-native-datepicker": "^1.7.2",
"react-native-map-link": "^2.1.6",
"react-native-maps": "^0.23.0",
"react-native-maps-directions": "^1.6.0",
"react-native-modal-datetime-picker": "^6.0.0",
"react-native-modal-dropdown": "^0.6.2",
"react-native-photo-upload": "^1.3.0",
"react-native-popover-tooltip": "^1.1.4",
"react-native-popup-dialog": "^0.15.1",
"react-native-rating": "^2.0.4",
"react-native-searchable-dropdown": "^1.0.5",
"react-native-side-menu": "^1.1.3",
"react-native-vector-icons": "^6.0.2",
"react-navigation": "^2.12.0"
},
答案 0 :(得分:0)
在元数据标签(而不是v2)中使用它:
android:name="com.google.android.geo.API_KEY"