简体   繁体   English

如果反应原生 android 构建失败,如何解决?

[英]How to fix if the react native android build is failed?

I am very new to React native app developer.我对 React 原生应用程序开发人员非常陌生。 Please help me to fix the below issue I am facing the below issues while executing react-native run-android.请帮我解决以下问题 我在执行 react-native run-android 时遇到以下问题。

info Running jetifier to migrate libraries to AndroidX. info 运行 jetifier 将库迁移到 AndroidX。 You can disable it using "--no-jetifier" flag.您可以使用“--no-jetifier”标志禁用它。 Jetifier found 1112 file(s) to forward-jetify. Jetifier 找到 1112 个文件来转发-jetify。 Using 8 workers... info Starting JS server... 'adb' is not recognized as an internal or external command, operable program or batch file. Using 8 workers... info 正在启动 JS 服务器... 'adb' 不是内部或外部命令、可运行程序或批处理文件。 info Launching emulator... error Failed to launch emulator. info 正在启动模拟器...错误无法启动模拟器。 Reason: No emulators found as an output of emulator -list-avds .原因:没有找到作为emulator -list-avds的 output 的模拟器。 warn Please launch an emulator manually or connect a device.警告 请手动启动模拟器或连接设备。 Otherwise app may fail to launch.否则应用程序可能无法启动。 info Installing the app... Starting a Gradle Daemon (subsequent builds will be faster) info 安装应用程序... 启动 Gradle 守护程序(后续构建会更快)

Task:app:processDebugResources FAILED任务:应用程序:进程调试资源失败

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.此版本中使用了已弃用的 Gradle 功能,使其与 Gradle 7.0 不兼容。 Use '--warning-mode all' to show the individual deprecation warnings.使用“--warning-mode all”显示各个弃用警告。 See https://docs.gradle.org/6.0.1/userguide/command_line_interface.html#sec:command_line_warnings 92 actionable tasks: 4 executed, 88 up-to-date请参阅https://docs.gradle.org/6.0.1/userguide/command_line_interface.html#sec:command_line_warnings 92 个可操作任务:4 个已执行,88 个最新

FAILURE: Build failed with an exception. FAILURE:构建失败并出现异常。

  • What went wrong: Execution failed for task ':app:processDebugResources'.出了什么问题:任务“:app:processDebugResources”执行失败。

    A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade Unable to delete directory 'E:\React Native\RNProjects\AHHCSTAFF\android\app\build\generated\not_namespaced_r_class_sources\debug\r\androidx\appcompat' after 10 attempts A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade Unable to delete directory 'E:\React Native\RNProjects\AHHCSTAFF\android\app\build\generated\not_namespaced_r_class_sources\debug\r\androidx\appcompat ' 尝试 10 次后

  • Try: Run with --stacktrace option to get the stack trace.尝试:使用 --stacktrace 选项运行以获取堆栈跟踪。 Run with --info or --debug option to get more log output.使用 --info 或 --debug 选项运行以获得更多日志 output。 Run with --scan to get full insights.运行 --scan 以获得完整的见解。

  • Get more help at https://help.gradle.orghttps://help.gradle.org获得更多帮助

BUILD FAILED in 43s 43 秒内构建失败

error Failed to install the app.错误 无法安装应用程序。 Make sure you have the Android development environment set up: https://reactnative.dev/docs/getting-started.html#android-development-environment .确保您已设置 Android 开发环境: https://reactnative.dev/docs/getting-started.html#android-development-environment Run CLI with --verbose flag for more details.使用 --verbose 标志运行 CLI 以获取更多详细信息。 Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081错误:命令失败:gradlew.bat app:installDebug -PreactNativeDevServerPort=8081

FAILURE: Build failed with an exception. FAILURE:构建失败并出现异常。

  • What went wrong: Execution failed for task ':app:processDebugResources'.出了什么问题:任务“:app:processDebugResources”执行失败。

    A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade Unable to delete directory 'E:\React Native\RNProjects\AHHCSTAFF\android\app\build\generated\not_namespaced_r_class_sources\debug\r\androidx\appcompat' after 10 attempts A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade Unable to delete directory 'E:\React Native\RNProjects\AHHCSTAFF\android\app\build\generated\not_namespaced_r_class_sources\debug\r\androidx\appcompat ' 尝试 10 次后

  • Try: Run with --stacktrace option to get the stack trace.尝试:使用 --stacktrace 选项运行以获取堆栈跟踪。 Run with --info or --debug option to get more log output.使用 --info 或 --debug 选项运行以获得更多日志 output。 Run with --scan to get full insights.运行 --scan 以获得完整的见解。

  • Get more help at https://help.gradle.orghttps://help.gradle.org获得更多帮助

BUILD FAILED in 43s 43 秒内构建失败

at makeError (E:\React Native\RNProjects\AHHCSTAFF\node_modules\execa\index.js:174:9)
at E:\React Native\RNProjects\AHHCSTAFF\node_modules\execa\index.js:278:16
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at async runOnAllDevices (E:\React Native\RNProjects\AHHCSTAFF\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\runOnAllDevices.js:94:5)
at async Command.handleAction (E:\React Native\RNProjects\AHHCSTAFF\node_modules\react-native\node_modules\@react-native-community\cli\build\index.js:186:9)

I dont know how to fix all the above issues我不知道如何解决上述所有问题

I have met this error logs before.我以前遇到过这个错误日志。 Here are my resolve steps:(executing in progect root dictory)这是我的解决步骤:(在 progect 根目录中执行)

cd android 
gradlew clean

And run yarn android ,it works well.By the way,my RN version is 0.62.运行yarn android ,效果很好。顺便说一下,我的 RN 版本是 0.62。 You can have a try.你可以试一试。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM