首页 > 解决方案 > 当我在 android 上运行 react native 时出现此错误:./gradlew app:installDebug -PreactNativeDevServerPort=8081

问题描述

它在 ios 中运行,但在 android 中运行显示此错误。

错误 无法安装应用程序。确保您已设置 Android 开发环境: https ://reactnative.dev/docs/getting-started.html#android-development-environment 。使用 --verbose 标志运行 CLI 以获取更多详细信息。错误:命令失败:./gradlew app:installDebug -PreactNativeDevServerPort=8081

FAILURE:构建失败并出现异常。

  • 出了什么问题:在项目“:app”中找不到任务“installDebug”。

  • 尝试:运行 gradlew 任务以获取可用任务列表。使用 --stacktrace 选项运行以获取堆栈跟踪。使用 --info 或 --debug 选项运行以获得更多日志输出。运行 --scan 以获得完整的见解。

  • 在https://help.gradle.org获得更多帮助

4 秒内构建失败

at makeError (/Users/sherin/CourierApp/node_modules/execa/index.js:174:9)
at /Users/sherin/CourierApp/node_modules/execa/index.js:278:16
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at async runOnAllDevices (/Users/sherin/CourierApp/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.js:94:5)
at async Command.handleAction (/Users/sherin/CourierApp/node_modules/@react-native-community/cli/build/index.js:186:9)

标签: javascriptandroidreactjsreact-native

解决方案


推荐阅读