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

安装react-native-codepush后出现:react-native-code-push项目解析失败问题

解决react-native-codepush安装后Android构建依赖错误

安装react-native-codepush后执行Android构建时出现以下错误:

Could not determine the dependencies of task ':app:mergeDebugAssets'.

Could not resolve all task dependencies for configuration ':app:debugRuntimeClasspath'.

Could not resolve project :react-native-code-push.

Required by:
project :app

No matching configuration of project :react-native-code-push was found. The consumer was configured to find a runtime of a component, preferably optimized for Android, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'debug' but:
- None of the consumable configurations have attributes.

解决方案:

  • 版本兼容性检查
    确认react-native-code-push版本与当前React Native版本匹配(比如RN 0.70+对应code-push 7.0+)。执行以下命令查看当前版本,不匹配则重装:

    npm list react-native-codepush
    npm uninstall react-native-codepush
    npm install react-native-codepush@适配版本号
    
  • 重新执行自动链接并清理缓存
    即使RN 0.60+支持自动链接,仍可能出现链接不完整的情况,执行:

    npx react-native link react-native-codepush
    cd android && ./gradlew clean
    
  • 手动补全Android项目配置

    1. 打开android/settings.gradle,确认添加以下配置:
      include ':react-native-code-push'
      project(':react-native-code-push').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-code-push/android/app')
      
    2. 打开android/app/build.gradle,确保dependencies块包含:
      implementation project(':react-native-code-push')
      
    3. 检查buildTypes配置,确保debug、release等构建类型存在,且CodePush部署key配置正确:
      buildTypes {
          debug {
              signingConfig signingConfigs.debug
              // 可选:添加调试环境CodePush key
              // codePushDeploymentKey "YOUR_DEBUG_KEY"
          }
          release {
              signingConfig signingConfigs.release
              codePushDeploymentKey "YOUR_PRODUCTION_KEY"
          }
      }
      
  • 升级Gradle相关版本
    打开android/build.gradle,更新Gradle插件版本到RN兼容的版本(如RN 0.70+对应7.2.0+):

    buildscript {
        dependencies {
            classpath("com.android.tools.build:gradle:7.2.3")
        }
    }
    

    修改android/gradle/wrapper/gradle-wrapper.properties中的Gradle版本:

    distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip
    

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.16 16:05:38