react native : npx react-native start ==> 找不到方法 exec()

问题描述 投票:0回答:1

我使用此视频的配置安装 android studio、node js、JDK 17:https://www.youtube.com/watch?v=G0wrlZvDjrE

但是当我使用 cmd 运行应用程序时:npx react-native start。 我收到此错误消息。

:ReactNative:Running '[node, -e, try {console.log(require('@react-native-community/cli').bin);} catch (e) {console.log(require('react-native/cli').bin);}]' command failed.

FAILURE: Build failed with an exception.

* Where:
Script 'C:\Users\valen\Documents\GitHub\SuperApp\node_modules\@react-native-community\cli-platform-android\native_modules.gradle' line: 397

* What went wrong:
A problem occurred evaluating script.
> Could not find method exec() for arguments [ReactNativeModules$_getCommandOutput_closure16@2520ef93] on object of type org.gradle.api.internal.provider.DefaultProviderFactory_Decorated.

* 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.

有人可以帮我解决这个问题吗?

谢谢你,

如果我运行:npx react-native run-android,我会收到一条错误消息,有点不同。

info 💡 Tip: Make sure that you have set up your development environment correctly, by running npx react-native doctor. To read more about doctor command visit: https://github.com/react-native-community/cli/blob/main/packages/cli-doctor/README.md#doctor 

:ReactNative:Running '[node, -e, try {console.log(require('@react-native-community/cli').bin);} catch (e) {console.log(require('react-native/cli').bin);}]' command failed.

FAILURE: Build failed with an exception.

* Where:
Script 'C:\Users\valen\Documents\GitHub\SuperApp\node_modules\@react-native-community\cli-platform-android\native_modules.gradle' line: 397

* What went wrong:
A problem occurred evaluating script.
> Could not find method exec() for arguments [ReactNativeModules$_getCommandOutput_closure16@5d05d47e] on object of type org.gradle.api.internal.provider.DefaultProviderFactory_Decorated.

* 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 1s
error Failed to install the app. Command failed with exit code 1: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
:ReactNative:Running '[node, -e, try {console.log(require('@react-native-community/cli').bin);} catch (e) {console.log(require('react-native/cli').bin);}]' command failed. FAILURE: Build failed with an exception. * Where: Script 'C:\Users\valen\Documents\GitHub\SuperApp\node_modules\@react-native-community\cli-platform-android\native_modules.gradle' line: 397 * What went wrong: A problem occurred evaluating script. > Could not find method exec() for arguments [ReactNativeModules$_getCommandOutput_closure16@5d05d47e] on object of type org.gradle.api.internal.provider.DefaultProviderFactory_Decorated. * 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 1s.
info Run CLI with --verbose flag for more details.

手机可以运行,但我没有应用程序。

我只更改了 C:\Users alen\Documents\GitHub\SuperApp ndroid\gradle\wrapper\gradle-wrapper 的 url,因为 gradle 的版本与 JDK 17 不匹配。然后我把 gradle 7.3 。

If i run npx react-native doctor, i have a error ==>  ✖ Android SDK - Required for building and installing your app on Android
   - Versions found: N/A

但是如果我解决这个问题并重新启动电脑,问题仍然存在:/

react-native android-studio gradle
1个回答
0
投票

转到

Android Studio > Settings > Languages & Frameworks > Android SDK
并首先检查是否:

  • SDK Platforms
    您确实安装了任何SDK
  • SDK Tools
    上,您有:
    Android SDK Build-Tools
    Android SDK Command-line Tools
    Android Emulator
    Android SDK Platform Tools activated

您可以做的另一件好事是在 Android Studio 上打开您的项目,看看是否存在有关 gradle、更新或在模拟器上运行项目之前需要解决的任何其他错误

© www.soinside.com 2019 - 2024. All rights reserved.