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

EAS Android构建失败:无法解析:react-native-code-push项目

Android EAS构建失败:react-native-code-push依赖解析错误

近期从expo build切换到EAS Build,iOS构建可正常完成,但Android构建持续失败,报错信息如下:

Error: [stderr] Build failed with an exception.
[stderr] * What went wrong:

[stderr] Could not determine the dependencies of task ':app:collectReleaseDependencies'.
[stderr] 
> Could not resolve all task dependencies for configuration ':app:releaseRuntimeClasspath'.
[stderr]  > Could not resolve project :react-native-code-push.
[stderr] Required by:
[stderr] project :app
[stderr] > No matching configuration of project :react-native-code-push was found. The consumer was configured to find a runtime of a component, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'release' but:
[stderr] - None of the consumable configurations have attributes.

我的eas.json配置文件如下:

{
  "cli": {
    "version": ">= 3.8.1"
  },
  "build": {
    "development": {
      "developmentClient": true,
      "distribution": "internal",
      "ios": {
        "resourceClass": "m-medium"
      }
    },
    "preview": {
      "distribution": "internal",
      "ios": {
        "resourceClass": "m-medium"
      }
    },
    "production": {
      "ios": {
        "resourceClass": "m-medium",
        "image": "macos-monterey-12.1-xcode-13.2"
      }
    }
  },
  "submit": {
    "production": {}
  }
}

解决方案

  • 升级react-native-code-push版本:确保使用的react-native-code-push版本适配EAS Build,建议升级到最新稳定版(>=7.0.0),旧版本对新Gradle配置兼容性较差。
  • 补全Android BuildType关联:在项目android/app/build.gradle的buildTypes块中,给release构建添加code-push的gradle插件引用:
    buildTypes {
        release {
            // 保留原有配置
            apply from: "../../node_modules/react-native-code-push/android/codepush.gradle"
        }
    }
    
  • 完善EAS的Android构建配置:在eas.json的preview/production构建项中补充Android相关配置,确保和本地Gradle构建类型匹配:
    "preview": {
      "distribution": "internal",
      "ios": { "resourceClass": "m-medium" },
      "android": {
        "buildType": "release",
        "gradleCommand": ":app:assembleRelease"
      }
    },
    "production": {
      "ios": {
        "resourceClass": "m-medium",
        "image": "macos-monterey-12.1-xcode-13.2"
      },
      "android": {
        "buildType": "release"
      }
    }
    
  • 清理缓存重新构建:执行eas build --platform android --clear-cache,清除EAS的构建缓存,避免旧依赖配置干扰。
  • 重置依赖:如果上述步骤无效,删除node_modules、package-lock.json(或yarn.lock),重新执行npm install(或yarn install)后再尝试构建。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.23 07:43:29