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

React Native构建Android应用遇protobuf-javalite版本约束问题求助

React Native Android构建错误解决方案(LogRocket 1.6.2相关)

错误详情

Task failed with an exception.

  • What went wrong:
    Execution failed for task ':app:checkDebugAarMetadata'.

Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
Could not resolve com.google.protobuf:protobuf-javalite:{strictly [3.0, 4.0[}.
Required by:
project :app > project :logrocket_react-native
Cannot find a version of 'com.google.protobuf:protobuf-javalite' that satisfies the version constraints:

使用的LogRocket版本:

"@logrocket/react-native": "1.6.2",

解决方法

  • 强制指定protobuf-javalite版本:在Android项目根目录的build.gradle(非app模块下的配置文件)中添加版本强制规则,锁定一个3.x范围内的稳定版本,比如3.21.12:
    allprojects {
        repositories {
            // 保留原有仓库配置
        }
        configurations.all {
            resolutionStrategy {
                force 'com.google.protobuf:protobuf-javalite:3.21.12'
            }
        }
    }
    
  • 升级LogRocket版本:若强制版本无效,尝试将@logrocket/react-native更新至最新兼容版本,新版本通常会修复依赖版本冲突问题。
  • 清理构建缓存后重试:执行以下命令清理缓存,再重新构建项目:
    ./gradlew clean
    rm -rf node_modules && npm install
    npx react-native run-android
    

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.03 02:20:45