react-native - react native 无法安装 react-native-maps (Android)

标签 react-native react-native-maps

我无法安装 react native react-native-maps,当我尝试使用 react-native run-android 构建时出现此错误(我还没有在 iOS 上尝试过):

A problem occurred configuring project ':app'. Could not resolve all dependencies for configuration ':app:_debugApk'. Configuration with name 'default' not found.

我按照这里的说明操作:

https://github.com/airbnb/react-native-maps/blob/master/docs/installation.md

当我运行时:

react-native link

我明白了:

rnpm-install info iOS module react-native-maps is already linked
rnpm-install info Android module react-native-geocoder is already linked
rnpm-install info iOS module react-native-geocoder is already linked

它似乎在 iOS 上运行但在 Android 上运行不正常,尽管对于地理编码器它运行正常(并且服务运行良好)。

所以我按照手册说明进行了编辑(但我仍然得到上面的错误):

android/app/build.gradle
android/settings.gradle
MainApplication.java
android\app\src\main\AndroidManifest.xml (was already edited for geocoder).

我确实玩了一下 build.gradle 中的版本号:

// instructed in the installation guide -> build fail see above
compile project(':react-native-maps')
// Version 0.12.1 and earlier -> Build success but ERROR 500 in the app
compile 'com.airbnb.android:react-native-maps:0.12.1'
// Version 0.12.2 and later -> error see below

A problem occurred configuring project ':app'. Could not resolve all dependencies for configuration ':app:_debugApkCopy'. Could not find com.airbnb.android:react-native-maps:0.12.2.

我尝试了不同的方法,但没有任何效果。我尝试了此链接中的内容(但它已被弃用):

cannot evaluate module 'react-native-maps' : Configuration with name 'default' not found

注意:我使用的是 react-native 0.42.0

最佳答案

我在 git hub 上针对 react-native-maps 项目发布了一个问题并得到了解决方案 there .

对于那些有同样问题的人,我的解决方案是更改 android/settings.gradle 的说明缺少/lib/

这给出了:

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

如果仍然无法正常工作,您可以尝试从 node_modules/react-native-maps/中删除 .babelrc

关于react-native - react native 无法安装 react-native-maps (Android),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43742424/

相关文章:

android - react native 谷歌登录开发人员错误代码 10

javascript - 本地图屏幕打开时,如何使 map View 以用户当前位置为中心? React Native 博览会

javascript - 找不到变量:useState

react-native - 如何防止 child 在新闻上被 parent 查看

ios - Xcode 设备不可用,未找到运行时配置文件

android - 在 react-native-map 中切换 maptype

javascript - 类型错误 : undefined is not an object( evaluating 'navigator.geolocation.getCurrentPosition' )

react-native - 如何访问 react-native-maps MapView 的所有 MapView.Markers?

javascript - react-native-maps:UrlTile 和 Polyline - zIndex/Overlaying 不工作

javascript - 通过导航 Prop 传递状态