开始我的项目时出现React Native Gradle问题

时间:2019-07-05 15:22:59

标签: react-native

我用过Linux Mint,启动本机应用程序后收到此消息。我已将Android设备连接到笔记本电脑。我没有使用任何模拟器。

sudo react-native run-android

> Task :app:installDebug FAILED

Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/5.4.1/userguide/command_line_interface.html#sec:command_line_warnings
26 actionable tasks: 1 executed, 25 up-to-date

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:installDebug'.
> com.android.builder.testing.api.DeviceException: No connected devices!

* Try:
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 7s

error Failed to install the app. Make sure you have an Android emulator running or a device connected. Run CLI with --verbose flag for more details.
Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:installDebug'.
> com.android.builder.testing.api.DeviceException: No connected devices!

* Try:
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 7s

    at checkExecSyncError (child_process.js:629:11)
    at execFileSync (child_process.js:647:13)
    at runOnAllDevices (/var/www/html/react/LotteryApp/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.js:75:39)
    at buildAndRun (/var/www/html/react/LotteryApp/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/index.js:137:41)
    at then.result (/var/www/html/react/LotteryApp/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/index.js:103:12)
    at process._tickCallback (internal/process/next_tick.js:68:7)

我尝试了很多类似--warning-mode all的事情,还有很多其他的事情。但我仍然收到此错误。我不知道该怎么办。

我正在使用Gradle版本5。 npm-6.9.0 节点-12.4.0 react-native-cli:2.0.1 反应本机:0.60.0

我能获得解决该问题的任何线索吗?请帮忙。预先感谢。

2 个答案:

答案 0 :(得分:0)

输出告诉您错误是什么:

  

com.android.builder.testing.api.DeviceException:没有连接的设备!

您需要启动Android模拟器或连接设备以在其上运行该应用程序。

答案 1 :(得分:0)

在阅读完与Michael的讨论之后,似乎您可能需要在Android设备中启用USB调试。

请按照以下步骤操作,如果在设备的Developer Options屏幕上看不到Settings

  1. 打开“设置”应用。
  2. (仅在Android 8.0或更高版本上)选择系统。
  3. 滚动到底部,然后选择关于手机。
  4. 滚动到底部,然后点击内部版本号7次。
  5. 返回上一个屏幕,在 底部。

在您的Developer Options中启用USB debugging选项。

现在,重新连接设备,它将要求您使用您PC的MAC地址进行许可:Allow USB Debugging。点击允许,然后运行

adb devices

您将在List of connected devices中看到设备的ID。