运行 npm react-native run-android 时突然出错。任务:app:processDebugResources 失败

Posted

技术标签:

【中文标题】运行 npm react-native run-android 时突然出错。任务:app:processDebugResources 失败【英文标题】:Sudden error while running the npm react-native run-android. Task :app:processDebugResources FAILED 【发布时间】:2021-08-03 10:44:05 【问题描述】:

我突然收到一条错误消息,提示任务 ':app:processDebugResources' 执行失败。 从 C:\Users\prabh\AppData\Local\Temp\gradle13962421950392783403.bin 偏移 114265 中的二进制存储读取数据时出现问题?真的 我认为这个错误与 react native firebase 有关。我正在使用 react-native-firebase/app、firebase/auth、firebase/messaging 包。我很长一段时间都在使用这些软件包,但以前从未遇到过问题。我在收到此错误前几个小时所做的唯一一件事是 npm audit fix 以修复一些漏洞。有人遇到过类似的错误吗?

build.gradle 依赖项:

    implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "com.facebook.react:react-native:+"  // From node_modules
implementation 'com.google.firebase:firebase-analytics:17.3.0' //For Notifications
implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0"
implementation project(':react-native-vector-icons')
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.0.0' // <-- add this; newer versions should work too
implementation project(':react-native-fs') //addes Manually compile project
implementation project(':react-native-get-real-path')
implementation 'com.facebook.fresco:fresco:2.0.0'
// For animated GIF support
implementation 'com.facebook.fresco:animated-gif:2.0.0'
// For WebP support, including animated WebP
implementation 'com.facebook.fresco:animated-webp:2.0.0'
implementation 'com.facebook.fresco:webpsupport:2.0.0'

【问题讨论】:

你在android studio中试过了吗,文件->缓存无效并重启->无效并重启 不,那没用 【参考方案1】:

这适用于我在 Windows 10 和 Android 上。我没有在 Mac 或 Linux 上尝试过。 我从https://github.com/gradle/gradle/issues/8489@jack7891 看到的 谢谢杰克。 安卓/build.gradle classpath 'com.google.gms:google-services:4.3.4' 到类路径 'com.google.gms:google-services:4.3.5'

android/app/build.gradle implementation 'com.google.firebase:firebase-analytics:17.3.0'implementation 'com.google.firebase:firebase-analytics:18.0.2'

package.json

 "@react-native-firebase/app": "^11.1.2",
 "@react-native-firebase/auth": "^11.1.2",
 "@react-native-firebase/firestore": "^11.1.2",
 "@react-native-firebase/storage": "^11.1.2",
 "@react-native-firebase/messaging": "^11.1.2",
 "react-native-push-notification": "^7.2.3",

 "@react-native-firebase/app": "^11.5.0",
 "@react-native-firebase/auth": "^11.5.0",
 "@react-native-firebase/firestore": "^11.5.0",
 "@react-native-firebase/storage": "^11.5.0",
 "@react-native-firebase/messaging": "^11.5.0",
 "react-native-push-notification": "^7.3.1",

然后运行npm installyarn install

之后,进入android项目文件夹并运行:

./gradlew.bat clean

最后,您可以进入项目文件夹并运行npx react-native run-android

【讨论】:

以上是关于运行 npm react-native run-android 时突然出错。任务:app:processDebugResources 失败的主要内容,如果未能解决你的问题,请参考以下文章

React Native - 运行“npm start”和“react-native run-android”时出错

运行 npm react-native run-android 时突然出错。任务:app:processDebugResources 失败

run-as 包 'a.b.c' 未知 - Galaxy S4 Jellybean 或 Android 4.3

npm install 在 react-native 中出现错误“gyp ERR!find VS”

.Net MAUI 'run-as' 命令失败,出现'run-as:无法设置功能:不允许操作

npm install 破坏了使用 expo 创建的 react-native 应用程序