首页 > 解决方案 > 任务“:app:processReleaseGoogleServices”执行失败。删除失败:...../values.xml

问题描述

我有一个 React Native 项目。我正在为 macOS 上的 android(我对 iOS 没有问题)构建发布版本。我一直在关注本指南:https ://facebook.github.io/react-native/docs/signed-apk-android 。当我运行时./gradlew assembleRelease,我收到以下错误:

:app:processReleaseGoogleServices
Parsing json file: /Users/robavery/repositories/ourdailystrength_app/android/app/google-services.json
:app:processReleaseGoogleServices FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:processReleaseGoogleServices'.
> Failed to delete: /Users/robavery/repositories/ourdailystrength_app/android/app/build/generated/res/google-services/release/values/values.xml

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 47s

当我尝试清理我的项目时(无论我是通过 Android Studio、./gradlew clean还是清理npm run clean:android),我已经清理并得到了同样的错误。

我尝试运行sudo ./gradlew assembleRelease,但后来我得到了这个错误:

> Task :app:processReleaseGoogleServices
Parsing json file: /Users/robavery/repositories/ourdailystrength_app/android/app/google-services.json


FAILURE: Build failed with an exception.

* What went wrong:
Failed to capture snapshot of input files for task ':app:bundleReleaseJsAndAssets' property '$1' during up-to-date check.
> Failed to create MD5 hash for file '/Users/robavery/repositories/ourdailystrength_app/.buckd/sock' as it does not exist.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 16s

不过,我宁愿能够以用户身份而不是 sudo 运行它。

是什么导致了这个错误?如何解决这个问题并成功地为发布进行 gradle 构建,而无需使用 sudo?

标签: androidreact-nativegradle

解决方案


如果问题是权限,这不是超级安全,但应该可以工作

sudo chmod -R 777 /Users/robavery/repositories/ourdailystrength_app

chmod用于修改777作为所有组的别名的 persions,所有权限,-R标志递归地运行它,以便您点击目录中的每个文件。

如果这不起作用,那么可以尝试清除您的项目缓存


推荐阅读