如何修复react-native run-android第一次运行错误



当我用react-native创建了一个项目并运行

react-native运行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:Usersa0105OneDrive바탕 ?���?momentumASnode_modulesreact-nativenode_modules@react-native-communityclibuildbin.js, config]' command.
:ReactNative:Running '[node, C:Usersa0105OneDrive바탕 ?���?momentumASnode_modulesreact-nativenode_modules@react-native-communityclibuildbin.js, config]' command failed.

FAILURE: Build failed with an exception.

* Where:
Script 'C:Usersa0105OneDrive���� ȭ��momentumASnode_modules@react-native-communitycli-platform-androidnative_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:Usersa0105OneDrive諛�?�? �솕硫�momentumASnode_modulesreact-nativenode_modules@react-native-communityclibuildbin.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:Usersa0105OneDrive바탕 ?���?momentumASnode_modulesreact-nativenode_modules@react-native-communityclibuildbin.js, config]' command.
:ReactNative:Running '[node, C:Usersa0105OneDrive바탕 ?���?momentumASnode_modulesreact-nativenode_modules@react-native-communityclibuildbin.js, config]' command failed.

FAILURE: Build failed with an exception.

* Where:
Script 'C:Usersa0105OneDrive���� ȭ��momentumASnode_modules@react-native-communitycli-platform-androidnative_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:Usersa0105OneDrive諛�?�? �솕硫�momentumASnode_modulesreact-nativenode_modules@react-native-communityclibuildbin.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:Usersa0105OneDrive바탕 화면momentumASnode_modulesexecaindex.js:174:9)
at C:Usersa0105OneDrive바탕 화면momentumASnode_modulesexecaindex.js:278:16
at processTicksAndRejections (internal/process/task_queues.js:95:5)
at async runOnAllDevices (C:Usersa0105OneDrive바탕 화면momentumASnode_modules@react-native-communitycli-platform-androidbuildcommandsrunAndroidrunOnAllDevices.js:106:5)
at async Command.handleAction (C:Usersa0105OneDrive바탕 화면momentumASnode_modulesreact-nativenode_modules@react-native-communityclibuildindex.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'��(��) ���� �Ǵ� �ܺ� ����, ������ �� �ִ� ���α׷�, �Ǵ�
��ġ ������ �ƴմϴ�.

i fix it

检查jdk8和使用物理设备