在项目":app"中找不到任务"安装调试" - 创建项目后运行-android



创建了一个react原生项目后,我尝试在我的android设备上运行它。我把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:Androidandroid-sdkplatform-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
081
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 Filesnodejsnode.EXE
Yarn: 1.17.3 - C:Program Files (x86)Yarnbinyarn.CMD
npm: 6.9.0 - C:Program Filesnodejsnpm.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本机。我把我的sdk的位置放在android文件夹下的local.properties中。我运行了gradlew installDebug,出现了installDebug not found in root project '[app's name]'。互联网上的解决方案都不起作用。

有人能帮我解决这个问题吗?非常感谢。

我也面临同样的问题。这是对我有效的。

我在安卓工作室打开了安卓项目。这可以位于YourReactActivitProjectFolder/android

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

我希望它会有所帮助。

最佳

解决方案是在android Studio中加载/android文件夹,并让它更新Gradle。之后,您将能够运行react-native run-android

在项目根目录下尝试以下命令:

cd android && ./gradlew assembleDebug && ./gradlew installDebug

对我来说=>Mac m1

1.-npx react原生运行的android提升了metro终端(保持metro开放(。

2.-在Android中的文件夹Android中打开proyect,并在设备上启动Emulator。(等待……(.

3.-稍后android启动应用程序和设备错误。

4.-在终端中键入"adb reverse tcp:8081 tcp:8801"(在文件夹android中(。

5.-在设备中按下重新加载

对不起,我的英语=(我希望它能帮助他们

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

cd安卓&amp/gradlew buildRelease

我遇到了同样的问题,这就是我解决它的方法。

  1. 我删除了react原生项目中的androidiOS文件夹。

  2. 我运行npx react native eject(如果你没有弹出,请通过运行yarn add eject来安装它。

  3. 我再次运行npx react原生运行android

最新更新