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

React Native Release Build构建失败求助:依赖解析超时问题

React Native构建因依赖问题失败

错误信息

FAILURE: Build failed with an exception.

* 出错原因:
任务 ':app:lintVitalRelease' 执行失败。
> 无法解析配置 ':react-native-community_checkbox:releaseRuntimeClasspath' 的所有构件。
   > 无法解析 com.facebook.react:react-native:+。
     被以下项目依赖:
         project :react-native-community_checkbox
      > 无法列出 com.facebook.react:react-native 的版本。
         > 无法从 https://jcenter.bintray.com/com/facebook/react/react-native/maven-metadata.xml 加载Maven元数据。
            > 无法获取资源 'https://jcenter.bintray.com/com/facebook/react/react-native/maven-metadata.xml'。
               > 无法发送GET请求至 'https://jcenter.bintray.com/com/facebook/react/react-native/maven-metadata.xml'。
                  > 读取超时

问题根源

JCenter仓库已停止维护并关闭服务,导致构建时无法从该仓库获取com.facebook.react:react-native的版本元数据,触发读取超时,进而导致lintVitalRelease任务失败。

解决方案

  • 替换JCenter仓库
    打开项目根目录下的android/build.gradle文件,修改allprojects中的repositories块,移除jcenter(),添加mavenCentral(),同时保留React Native必需的本地仓库:

    allprojects {
        repositories {
            mavenCentral()
            maven { url("$rootDir/../node_modules/react-native/android") }
            maven { url("$rootDir/../node_modules/jsc-android/dist") }
            google()
        }
    }
    
  • 锁定React Native具体版本
    避免使用+自动匹配版本,在android/app/build.gradle的dependencies块中,将com.facebook.react:react-native:+替换为你项目实际使用的React Native版本(可查看项目根目录package.json中的react-native版本),例如:

    dependencies {
        implementation 'com.facebook.react:react-native:0.72.6'
        // 其他依赖...
    }
    

    若react-native-community_checkbox依赖的版本范围仍有问题,可在android/build.gradle中添加版本强制策略:

    configurations.all {
        resolutionStrategy {
            force 'com.facebook.react:react-native:0.72.6' // 替换为你的RN版本
        }
    }
    
  • 清理构建缓存
    执行以下命令清理缓存,确保新配置生效:

    ./gradlew clean
    rm -rf node_modules && npm install
    rm -rf android/.gradle android/build android/app/build
    

内容的提问来源于stack exchange,提问作者Punit kumar

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.15 01:46:06