我是一个新手,对react native。我开始了一个新的项目,并按照所有的步骤进行操作。我之前有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
请你帮我解决这个问题好吗?
如上所述 此处你可以尝试在项目的根目录下运行以下命令。
cd android && ./gradlew installDevDebug && cd .. && react-native run-android --variant=DevDebug
在这之后,你的项目应该可以在你的Android上成功运行。
如果没有,用android studio打开你的项目,然后再用 react-native run-android
如果在这之后,你的项目仍然没有工作,请确保你已经有了一个新的项目。ANDROID_HOME
变量的PATH变量