You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

react-native-google-places安卓构建失败:找不到com.google.android.gms:play-services-base:11.6.2

解决react-native-google-places Android构建失败:找不到play-services-base:11.6.2的问题

嘿,我之前也碰到过一模一样的问题!这个错误本质是Google Play Services依赖版本不对齐,或者Android项目的Maven仓库配置缺失,导致Gradle找不到指定版本的包。给你几个亲测有效的解决办法:

  • 统一Google Play Services版本
    打开项目根目录下的android/build.gradle,找到ext配置块(如果没有就新建一个),确保googlePlayServicesVersion设置为11.6.2或者和你项目其他依赖兼容的版本:

    ext {
      buildToolsVersion = "30.0.2"
      minSdkVersion = 21
      compileSdkVersion = 30
      targetSdkVersion = 30
      googlePlayServicesVersion = "11.6.2" // 关键:和组件依赖的版本保持一致
    }
    

    这样能避免不同依赖之间的Play Services版本冲突。

  • 确认Google Maven仓库已配置
    同样在android/build.gradle的allprojects -> repositories中,必须添加Google官方的Maven仓库,不然Gradle找不到Play Services的包:

    allprojects {
      repositories {
        mavenCentral()
        google() // 这个是核心,不能少
        maven { url 'https://jitpack.io' }
        maven { url "https://maven.google.com" } // 旧版本兼容写法,可加可不加
      }
    }
    
  • 清理缓存后重新构建
    有时候旧的构建缓存会干扰依赖解析,运行以下命令清理后再重新构建:

    cd android
    ./gradlew clean
    cd ..
    npx react-native run-android
    
  • 检查组件版本兼容性
    如果你用的是较老版本的react-native-google-places,它依赖的Play Services版本可能比较陈旧。可以尝试升级组件到最新稳定版,或者查看组件文档确认它支持的Play Services版本范围,再调整项目的对应配置。

试试这些步骤,应该能搞定你的构建问题!我当时是靠统一版本+配置Google仓库解决的😉

内容的提问来源于stack exchange,提问作者E.D

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.25 04:12:42