如何编译react-native android?

qvtsj1bj  于 2022-12-04  发布在  React
关注(0)|答案(2)|浏览(177)

我已经创建了一个react原生应用程序。我是按照“React”官方网站上的说明来做的。但是我的react原生android项目无法启动。控制台:

info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 1289 file(s) to forward-jetify. Using 8 workers...
info Starting JS server...
info Installing the app...
:ReactNative:Unexpected empty result of running '[node, C:\Users\Кирилл\Desktop\helloWorld\MyReactNative\node_modules\@react-native-community\cli\build\bin.js, config]' command.
:ReactNative:Running '[node, C:\Users\Кирилл\Desktop\helloWorld\MyReactNative\node_modules\@react-native-community\cli\build\bin.js, config]' command failed.

FAILURE: Build failed with an exception.

* Where:
Script 'C:\Users\������\Desktop\helloWorld\MyReactNative\node_modules\@react-native-community\cli-platform-android\native_modules.gradle' line: 195

* What went wrong:
A problem occurred evaluating script.
> node:internal/modules/cjs/loader:903  throw err;  ^Error: Cannot find module 'C:\Users\Кирилл\Desktop\helloWorld\MyReactNative\node_modules\@react-native-community\cli\build\bin.js'    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:900:15)    at Function.Module._load (node:internal/modules/cjs/loader:745:27)    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:72:12)    at node:internal/main/run_main_module: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 9s

error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup. Run CLI with --verbose flag for more details.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
:ReactNative:Unexpected empty result of running '[node, C:\Users\Кирилл\Desktop\helloWorld\MyReactNative\node_modules\@react-native-community\cli\build\bin.js, config]' command.
npm ERR! code 1
npm ERR! path C:\Users\Кирилл\Desktop\helloWorld\MyReactNative
npm ERR! command failed
npm ERR! command C:\Windows\system32\cmd.exe /d /s /c "react-native run-android"

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Кирилл\AppData\Local\npm-cache\_logs\2020-11-13T08_19_01_474Z-debug.log

我该怎么办?

ctzwtxfj

ctzwtxfj1#

我在驱动器D上有Android SDK,在驱动器C上有JDK。因为这个,什么都不起作用。我已经重新安装了Android Studio,SDK和JDK。一切都起作用了。

omjgkv6w

omjgkv6w2#

我在react原生项目版本0.61中也遇到了同样的问题。我可以通过将gradle版本更改为6.9来解决这个问题。
我以前的gradle版本是6.4.1

相关问题