我是新手,对本地人有反应。我开始了一个新项目,并遵循了所有步骤。我以前有Android Studio,然后用它启动了模拟器。运行npx react-native run-android
命令后,出现此错误。
**FAILURE: Build failed with an exception.
* What went wrong:
Task 'installDebug' not found in project ':app'.
* Try:
Run gradlew tasks to get a list of available tasks. 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 34s
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
FAILURE: Build failed with an exception.
* What went wrong:
Task 'installDebug' not found in project ':app'.
* Try:
Run gradlew tasks to get a list of available tasks. 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 34s**
然后我运行了abd -d
命令,我明白了。
Android Debug Bridge version 1.0.41
Version 29.0.6-6198805
Installed as C:\Users\User\AppData\Local\Android\Sdk\platform-tools\adb.exe
您能帮我吗?
答案 0 :(得分:1)
如here所述,您可以尝试在项目的根文件夹上运行以下命令:
cd android && ./gradlew installDevDebug && cd .. && react-native run-android --variant=DevDebug
此后,您的项目应成功在Android上运行。
否则,请使用android studio一次打开您的项目,然后使用react-native run-android
即使在此之后所有项目都无法正常工作,请确保PATH变量上已经有ANDROID_HOME
变量