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
相关产品推荐
相关产品推荐

