android - 我如何修复 react-native run-android 首次运行错误
问题描述
当我使用 react-native 创建一个项目并运行
react-native run-android
构建失败,如下面的日志所示。我如何解决它?
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
(node:29740) Warning: Accessing non-existent property 'padLevels' of module exports inside circular dependency
(Use `node --trace-warnings ...` to show where the warning was created)
Jetifier found 879 file(s) to forward-jetify. Using 12 workers...
info Starting JS server...
info Installing the app...
:ReactNative:Unexpected empty result of running '[node, C:\Users\a0105\OneDrive\바탕 ?���?\momentum\AS\node_modules\react-native\node_modules\@react-native-community\cli\build\bin.js, config]' command.
:ReactNative:Running '[node, C:\Users\a0105\OneDrive\바탕 ?���?\momentum\AS\node_modules\react-native\node_modules\@react-native-community\cli\build\bin.js, config]' command failed.
FAILURE: Build failed with an exception.
* Where:
Script 'C:\Users\a0105\OneDrive\���� ȭ��\momentum\AS\node_modules\@react-native-community\cli-platform-android\native_modules.gradle' line: 213
* What went wrong:
A problem occurred evaluating script.
> internal/modules/cjs/loader.js:905 throw err; ^Error: Cannot find module 'C:\Users\a0105\OneDrive\諛�?�? �솕硫�\momentum\AS\node_modules\react-native\node_modules\@react-native-community\cli\build\bin.js' at Function.Module._resolveFilename (internal/modules/cjs/loader.js:902:15) at Function.Module._load (internal/modules/cjs/loader.js:746:27) at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12) at internal/main/run_main_module.js:17:47 { code: 'MODULE_NOT_FOUND', requireStack: []}
* 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 3s
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.bat app:installDebug -PreactNativeDevServerPort=8081
:ReactNative:Unexpected empty result of running '[node, C:\Users\a0105\OneDrive\바탕 ?���?\momentum\AS\node_modules\react-native\node_modules\@react-native-community\cli\build\bin.js, config]' command.
:ReactNative:Running '[node, C:\Users\a0105\OneDrive\바탕 ?���?\momentum\AS\node_modules\react-native\node_modules\@react-native-community\cli\build\bin.js, config]' command failed.
FAILURE: Build failed with an exception.
* Where:
Script 'C:\Users\a0105\OneDrive\���� ȭ��\momentum\AS\node_modules\@react-native-community\cli-platform-android\native_modules.gradle' line: 213
* What went wrong:
A problem occurred evaluating script.
> internal/modules/cjs/loader.js:905 throw err; ^Error: Cannot find module 'C:\Users\a0105\OneDrive\諛�?�? �솕硫�\momentum\AS\node_modules\react-native\node_modules\@react-native-community\cli\build\bin.js' at Function.Module._resolveFilename (internal/modules/cjs/loader.js:902:15) at Function.Module._load (internal/modules/cjs/loader.js:746:27) at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12) at internal/main/run_main_module.js:17:47 { code: 'MODULE_NOT_FOUND', requireStack: []}
* 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 3s
at makeError (C:\Users\a0105\OneDrive\바탕 화면\momentum\AS\node_modules\execa\index.js:174:9)
at C:\Users\a0105\OneDrive\바탕 화면\momentum\AS\node_modules\execa\index.js:278:16
at processTicksAndRejections (internal/process/task_queues.js:95:5)
at async runOnAllDevices (C:\Users\a0105\OneDrive\바탕 화면\momentum\AS\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\runOnAllDevices.js:106:5)
at async Command.handleAction (C:\Users\a0105\OneDrive\바탕 화면\momentum\AS\node_modules\react-native\node_modules\@react-native-community\cli\build\index.js:192:9)
info Run CLI with --verbose flag for more details.]
我尝试了很多方法,但没有奏效。使用expo执行成功。
当我运行 react-native info 时,会出现下面的日志。
info Fetching system and libraries information...
(node:29320) Warning: Accessing non-existent property 'padLevels' of module exports inside circular dependency
(Use `node --trace-warnings ...` to show where the warning was created)
error Unable to print environment info.
Error: Command failed: wmic os get Caption
'wmic'��(��) ���� �Ǵ� �ܺ� ����, ������ �� �ִ� ���α�, �Ǵ�
��ġ ������ �ƴմϴ�.
解决方案
我修复它
检查 jdk8 并使用物理设备
推荐阅读
- c - 当一切都可以通过寄存器完成时,为什么要减少 %rsp?
- django - Django Query 中的除法
- python - Single shot multi-dimension indexing in torch - perhaps with index_select or gather?
- styled-components - 如何将一个 styled-components 组件的样式应用于另一个?
- python - 我正在尝试使用对象名称发件人生成一个脚本,但它不起作用
- javascript - 如何使用 firstdata - React & node js 付款?
- jmeter - 从相同的标题但不同的 xml 响应中提取数据
- python - 在 Numba 中,如何调用在 GPU 上运行的递归函数?
- ruby - “折叠”一个哈希数组,需要递归吗?
- laravel - 显示在下拉 Laravel 中选择的国家/地区的电话代码