gpt4 book ai didi

由于 gradle 缓存中缺少文件,React-native android 构建失败?

转载 作者:行者123 更新时间:2023-12-05 02:27:55 40 4
gpt4 key购买 nike

我目前正在为 ios 和 android 开发一个 react-native。我想添加 4 个新包(react-native-gesture-handlerreact-native-reanimatedreact-native-safe-area-context code> 和 @gorhom/bottom-sheet) 然后在安装时给我带来了一些麻烦所以我切换到另一个包可以毫无问题地替换这 4 个。
现在的问题是,即使在将项目回滚到之前的状态后,运行 npm run-android 时它仍然会崩溃,并出现错误:

> hbmggmbh_app@0.0.1 android
> react-native run-android

info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 1001 file(s) to forward-jetify. Using 8 workers...
info JS server already running.
info Launching emulator...
info Successfully launched emulator.
info Installing the app...
> Task :app:checkDebugAarMetadata FAILED

Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.

You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

See https://docs.gradle.org/7.3.3/userguide/command_line_interface.html#sec:command_line_warnings
12 actionable tasks: 2 executed, 10 up-to-date

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:checkDebugAarMetadata'.
> Multiple build operations failed.
java.nio.file.NoSuchFileException: /Users/private/.gradle/caches/transforms-3/acdba564cab10d0f31716104c08ecbee/results.bin
java.nio.file.NoSuchFileException: /Users/private/.gradle/caches/transforms-3/0051ba15206e71d5f2b7a6f0ed776860/results.bin
java.nio.file.NoSuchFileException: /Users/private/.gradle/caches/transforms-3/4e2e869708901347ef158aa1a9aed1f4/results.bin
java.nio.file.NoSuchFileException: /Users/private/.gradle/caches/transforms-3/f684783603be85eb4c827960e04e8a60/results.bin
java.nio.file.NoSuchFileException: /Users/private/.gradle/caches/transforms-3/e027a88f08932b9116d6e1bd45f24a79/results.bin
java.nio.file.NoSuchFileException: /Users/private/.gradle/caches/transforms-3/c08ba6ec0daadcde11699fa34d40b295/results.bin
java.nio.file.NoSuchFileException: /Users/private/.gradle/caches/transforms-3/c0b89d21d6409c50b59e277bb5915751/results.bin
java.nio.file.NoSuchFileException: /Users/private/.gradle/caches/transforms-3/f38a0e4adb2cb6c27096544b7d9f257a/results.bin
java.nio.file.NoSuchFileException: /Users/private/.gradle/caches/transforms-3/49b1d43dd024794a47163e54aa8a0a89/results.bin
java.nio.file.NoSuchFileException: /Users/private/.gradle/caches/transforms-3/52f1cba1c3b05bb59b006a525e2f4d4d/results.bin
...and 87 more failures.
> java.nio.file.NoSuchFileException: /Users/private/.gradle/caches/transforms-3/acdba564cab10d0f31716104c08ecbee/results.bin
> java.nio.file.NoSuchFileException: /Users/private/.gradle/caches/transforms-3/0051ba15206e71d5f2b7a6f0ed776860/results.bin
> java.nio.file.NoSuchFileException: /Users/private/.gradle/caches/transforms-3/22f4e52b551ac1cfb5cd025e9c5de9c1/results.bin
> java.nio.file.NoSuchFileException: /Users/private/.gradle/caches/transforms-3/d4405dbab538bff995a2a0c862019c94/results.bin
[... and so on for about ~50 more files]

* 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 4s

error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup.
Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:checkDebugAarMetadata'.
> Multiple build operations failed.
java.nio.file.NoSuchFileException: /Users/private/.gradle/caches/transforms-3/acdba564cab10d0f31716104c08ecbee/results.bin
java.nio.file.NoSuchFileException: /Users/private/.gradle/caches/transforms-3/0051ba15206e71d5f2b7a6f0ed776860/results.bin
java.nio.file.NoSuchFileException: /Users/private/.gradle/caches/transforms-3/4e2e869708901347ef158aa1a9aed1f4/results.bin
java.nio.file.NoSuchFileException: /Users/private/.gradle/caches/transforms-3/f684783603be85eb4c827960e04e8a60/results.bin
java.nio.file.NoSuchFileException: /Users/private/.gradle/caches/transforms-3/e027a88f08932b9116d6e1bd45f24a79/results.bin
java.nio.file.NoSuchFileException: /Users/private/.gradle/caches/transforms-3/c08ba6ec0daadcde11699fa34d40b295/results.bin
java.nio.file.NoSuchFileException: /Users/private/.gradle/caches/transforms-3/c0b89d21d6409c50b59e277bb5915751/results.bin
java.nio.file.NoSuchFileException: /Users/private/.gradle/caches/transforms-3/f38a0e4adb2cb6c27096544b7d9f257a/results.bin
java.nio.file.NoSuchFileException: /Users/private/.gradle/caches/transforms-3/49b1d43dd024794a47163e54aa8a0a89/results.bin
java.nio.file.NoSuchFileException: /Users/private/.gradle/caches/transforms-3/52f1cba1c3b05bb59b006a525e2f4d4d/results.bin
...and 87 more failures.
> java.nio.file.NoSuchFileException: /Users/private/.gradle/caches/transforms-3/acdba564cab10d0f31716104c08ecbee/results.bin
> java.nio.file.NoSuchFileException: /Users/private/.gradle/caches/transforms-3/0051ba15206e71d5f2b7a6f0ed776860/results.bin
> java.nio.file.NoSuchFileException: /Users/private/.gradle/caches/transforms-3/22f4e52b551ac1cfb5cd025e9c5de9c1/results.bin
> java.nio.file.NoSuchFileException: /Users/private/.gradle/caches/transforms-3/d4405dbab538bff995a2a0c862019c94/results.bin
[... and so on for about ~50 more files]

* 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 4s

at makeError (/Volumes/privateWorkspace/hbmggmbh/LF2Frontend/node_modules/@react-native-community/cli-platform-android/node_modules/execa/index.js:174:9)
at /Volumes/privateWorkspace/hbmggmbh/LF2Frontend/node_modules/@react-native-community/cli-platform-android/node_modules/execa/index.js:278:16
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async runOnAllDevices (/Volumes/privateWorkspace/hbmggmbh/LF2Frontend/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.js:109:5)
at async Command.handleAction (/Volumes/privateWorkspace/hbmggmbh/LF2Frontend/node_modules/@react-native-community/cli/build/index.js:192:9)
info Run CLI with --verbose flag for more details.

在我修复我在尝试实现我所说的 4 个包时遇到的其他错误时,我运行了 rm -r $HOME/.gradle/caches/ 这是一个解决方案我找到了 here在 stackoverflow 上,当时工作。因为它只是删除缓存,所以我没有多想。

项目现在“运行”于:

"dependencies": {
"prop-type": "^0.0.1",
"react": "18.0.0",
"react-native": "0.69.0",
"react-native-geolocation-service": "^5.3.0",
"react-native-maps": "^0.31.1"
},
"devDependencies": {
"@babel/core": "^7.12.9",
"@babel/runtime": "^7.12.5",
"@react-native-community/eslint-config": "^2.0.0",
"babel-jest": "^26.6.3",
"eslint": "^7.32.0",
"jest": "^26.6.3",
"metro-react-native-babel-preset": "^0.70.3",
"react-native-sass-transformer": "^2.0.0",
"react-test-renderer": "18.0.0"
}

我使用的版本:

------------------------------------------------------------
Gradle 7.4.2
------------------------------------------------------------

Build time: 2022-03-31 15:25:29 UTC
Revision: 540473b8118064efcc264694cbcaa4b677f61041

Kotlin: 1.5.31
Groovy: 3.0.9
Ant: Apache Ant(TM) version 1.10.11 compiled on July 10 2021
JVM: 18.0.1.1 (Homebrew 18.0.1.1+0)
OS: Mac OS X 12.1 x86_64

我尝试解决的问题列表:

  • 重新安装gradle
  • 重新安装 android studio 和我所有的模拟器
  • 运行 gradle --build-cache
  • 运行 gradle cleanBuildCache
    • 这导致在根项目“LF2Frontend”中找不到任务“cleanBuildCache”。错误
  • 删除 node_modules/package-lock.json 然后再次运行 npm i
  • 清除 native 缓存
  • 清除 npm 缓存
  • 最绝望的是:我尝试将我的一位队友的 gradle 缓存 .gradle/caches/transforms-3/ 复制到我的缓存文件夹中,希望这能有所作为。

在这一点上,我完全迷失了,也很困惑怎么会发生这样的事情。
有人知道如何解决这个问题吗?提前致谢

最佳答案

执行 rm -rf ~/.gradle/caches/ 后,我遇到了完全相同的情况。

最终通过删除整个 ~/.gradle 文件夹解决了这个问题,而不仅仅是 caches 子目录。

然后,在再次运行 react-native run-android 之后,React Native 开始自动重建 Gradle 工件。然后我的 RN Android 构建再次成功。

希望这对您有所帮助!

关于由于 gradle 缓存中缺少文件,React-native android 构建失败?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72830273/

40 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com