首页 > 解决方案 > React Native Maps 依赖问题

问题描述

我目前正在尝试将谷歌地图集成到我的 react native 应用程序(android 端)中,并遵循官方文档中提供的所有安装步骤,但存在一些依赖性问题。

在尝试了数以千计的可用解决方案之后,终于将其发布在这里。

ERROR: Unable to resolve dependency for ':react-native- 
maps@debug/compileClasspath': Could not resolve 
com.android.support:support-annotations:25.2.0.
Show Details
Affected Modules: react-native-maps


ERROR: Unable to resolve dependency for ':react-native- 
maps@debug/compileClasspath': Could not resolve 
com.android.support:support-core-utils:25.2.0.
Show Details
Affected Modules: react-native-maps

我从

maven { // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm url "$rootDir/../node_modules/react-native/android" }

`maven {
        url 'https://maven.google.com/'
        name 'Google'
    }`

它修复了 react-native-maps 的依赖问题,但遇到了另一个问题

'error: cannot find symbol
 @ReactMethod(isBlockingSynchronousMethod = true)'

我同时添加了两个 Maven 资源,以便可以像这样相应地获取依赖项

`allprojects {
repositories {
    mavenLocal()
    google()
    jcenter()

    maven {
        // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
        url "$rootDir/../node_modules/react-native/android"
    }
    maven {
        url 'https://maven.google.com/'
        name 'Google'
    }
}
}

但再次遇到地图依赖问题。请注意,当我将 maven.google.com 添加为获取依赖项的唯一资源时,依赖项问题得到修复。

标签: mavengoogle-mapsreact-nativegradle

解决方案


推荐阅读