在项目':app'中没有找到任务'installDebug'--在创建项目后运行-roid

3 人关注

在创建了一个react native项目后,我试图在我的安卓设备上运行它。我在终端中输入 adb devices ,我看到了我的设备。我运行了 react-native run-android 。过了一会儿, Task 'installDebug' not found in project ':app' 弹了出来。

Jetifier found 962 file(s) to forward-jetify. Using 4 workers
...info Starting JS server...
'D:\Android\android-sdk\platform-tools' is not recognized as an internal or external command, operable program or batch file.
info Launching emulator...
error Failed to launch emulator. Reason: No emulators found as an output of `emulator -list-avds`.
warn Please launch an emulator manually or connect a device. Otherwise app may fail to launch.
info Installing the app...
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.0.1/userguide/command_line_interface.html#sec:command_line_warnings
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 15s
error Failed to install the app. Make sure you have the Android development environment set up:
https://reactnative.dev/docs/getting-started.html#android-development-environment. Run CLI with --verbose flag for more details.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8
FAILURE: Build failed with an exception.
* What went wrong:
Task 'installDebug' not found in project ':app'.

这里是反应-原生信息

info Fetching system and libraries information...
System:
    OS: Windows 7 6.1.7601
    CPU: (4) x64 Intel(R) Core(TM) i3-2100 CPU @ 3.10GHz
    Memory: 881.91 MB / 3.97 GB
  Binaries:
    Node: 10.16.1 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.17.3 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
    npm: 6.9.0 - C:\Program Files\nodejs\npm.CMD
    Watchman: Not Found
  SDKs:
    Android SDK: Not Found
  IDEs:
    Android Studio: Version  3.2.0.0 AI-181.5540.7.32.5014246
  Languages:
    Python: Not Found
  npmPackages:
    @react-native-community/cli: Not Found
    react: 16.11.0 => 16.11.0
    react-native: 0.62.0 => 0.62.0
  npmGlobalPackages:
    *react-native*: Not Found

我运行了gradlew tasks,在安装任务下没有看到installDebug。我确信我正确设置了环境变量,包括android SDK、JDK。我试着重新安装了react-native。我把sdk的位置放在android文件夹下的local.properties中。我运行了gradlew installDebug,出现了installDebug not found in root project '[app's name]'。互联网上的解决方案都没有用。

谁能帮助我解决这个问题?

android
react-native
putawanDE
putawanDE
发布于 2020-03-28
5 个回答
Abbas
Abbas
发布于 2022-07-18
已采纳
0 人赞同

我也面临同样的问题。 以下是对我有用的方法。

我在Android Studio中打开了Android项目。 它可以位于YourReactNativeProjectFolder/android

当我在Android Studio中打开这个项目时,它缺少配置。等待一段时间,让Android Studio对其进行配置并要求你更新Gradle。更新Gradle,现在你可以从Android Studio或使用命令行" npx react-native run-android "运行你的项目。

我希望这将是有帮助的。

Andrei Vedovato
Andrei Vedovato
发布于 2022-07-18
0 人赞同

在项目根部尝试以下命令。

cd android && ./gradlew assembleDebug && ./gradlew installDebug
    
assembleDebug不起作用 【替换代码0
EWR
EWR
发布于 2022-07-18
0 人赞同

解决办法是在Android Studio中加载/android文件夹,让它更新Gradle。之后,你就可以运行 react-native run-android 了。

Mobarak Hossen
Mobarak Hossen
发布于 2022-07-18
0 人赞同

我有同样的错误。试试下面的命令,它将显示代码的确切错误。

cd android && ./gradlew buildRelease

Isaac Barrera
Isaac Barrera
发布于 2022-07-18
0 人赞同

for me => Mac m1

1.- npx react-native run-android raises metro terminal(stay open metro)。

2.- 在Android文件夹中打开proyect,并在设备上启动Emulator。(wait....)。