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

时间:2017-12-31 00:57:17

标签: react-native ubuntu-16.04 react-native-android

Scanning folders for symlinks in /home/sino/Desktop/we-clone/node_modules (4ms)
Starting JS server...
Building and installing the app on the device (cd android && ./gradlew installDebug)...
Incremental java compilation is an incubating feature.
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:checkDebugManifest
:app:preReleaseBuild UP-TO-DATE
:app:prepareComAndroidSupportAppcompatV72301Library UP-TO-DATE
:app:prepareComAndroidSupportSupportV42301Library UP-TO-DATE
:app:prepareComFacebookFbuiTextlayoutbuilderTextlayoutbuilder100Library UP-TO-DATE
:app:prepareComFacebookFrescoDrawee130Library UP-TO-DATE
:app:prepareComFacebookFrescoFbcore130Library UP-TO-DATE
:app:prepareComFacebookFrescoFresco130Library UP-TO-DATE
:app:prepareComFacebookFrescoImagepipeline130Library UP-TO-DATE
:app:prepareComFacebookFrescoImagepipelineBase130Library UP-TO-DATE
:app:prepareComFacebookFrescoImagepipelineOkhttp3130Library UP-TO-DATE
:app:prepareComFacebookReactReactNative0493Library UP-TO-DATE
:app:prepareComFacebookSoloaderSoloader010Library UP-TO-DATE
:app:prepareOrgWebkitAndroidJscR174650Library UP-TO-DATE
:app:prepareDebugDependencies
:app:compileDebugAidl UP-TO-DATE
:app:compileDebugRenderscript UP-TO-DATE
:app:generateDebugBuildConfig UP-TO-DATE
:app:mergeDebugShaders UP-TO-DATE
:app:compileDebugShaders UP-TO-DATE
:app:generateDebugAssets UP-TO-DATE
:app:mergeDebugAssets UP-TO-DATE
:app:generateDebugResValues UP-TO-DATE
:app:generateDebugResources UP-TO-DATE
:app:mergeDebugResources UP-TO-DATE
:app:bundleDebugJsAndAssets SKIPPED
:app:processDebugManifest UP-TO-DATE
:app:processDebugResources UP-TO-DATE
:app:generateDebugSources UP-TO-DATE
:app:incrementalDebugJavaCompilationSafeguard UP-TO-DATE
:app:compileDebugJavaWithJavac UP-TO-DATE
:app:compileDebugNdk UP-TO-DATE
:app:compileDebugSources UP-TO-DATE
:app:transformClassesWithDexForDebug UP-TO-DATE
:app:mergeDebugJniLibFolders UP-TO-DATE
:app:transformNative_libsWithMergeJniLibsForDebug UP-TO-DATE
:app:processDebugJavaRes UP-TO-DATE
:app:transformResourcesWithMergeJavaResForDebug UP-TO-DATE
:app:validateSigningDebug
:app:packageDebug UP-TO-DATE
:app:assembleDebug UP-TO-DATE
:app:installDebug
07:52:34 E/adb: * daemon not running; starting now at tcp:5037
07:52:37 E/adb: * daemon started successfully
:app:installDebug FAILED

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.

BUILD FAILED

Total time: 8.916 secs
Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/android-setup.html

4 个答案:

答案 0 :(得分:7)

您需要运行Android模拟器或连接物理设备并处于USB调试模式。

有关详细信息,请参阅https://facebook.github.io/react-native/docs/getting-started.html#preparing-the-android-device

答案 1 :(得分:2)

如果您安装了android studio(如果未安装),则使用虚拟项目启动android studio,请转到“工具”->“ AVD管理器” 。确保创建一个虚拟设备并启动它。

enter image description here

enter image description here

注意:要创建此虚拟设备,您需要先在其上下载并安装兼容的OS(与项目的Android SDK版本兼容-SDK版本可在 build.gradle 文件中找到)。发射。 AVD Manager将指导您完成该过程。

另一件事,您可能使用的是真正的Android设备而不是模拟器,但仍然收到此消息。如果您的设备通过USB连接到笔记本电脑,则需要先启用开发者选项:

  

如果使用股票Android,请转到“设置”>“关于手机”>“内部版本号”。   在Samsung Galaxy设备上,转到设置>关于设备>构建   数。在HTC设备上,转到“设置”>“关于”>“软件”   信息>更多>内部编号。在LG设备上,转到设置>   关于电话>软件信息>内部版本号。点击版本号七   次。轻按几下后,您应该会看到步骤计数   向下,直到您解锁开发人员选项。激活后,您将   看到一条消息,写着“您现在是开发人员!”,请返回   设置,在菜单中可以找到开发人员选项条目。   (https://www.digitaltrends.com/mobile/how-to-get-developer-options-on-android/

然后在开发人员选项中,您应该启用 USB调试

enter image description here

答案 2 :(得分:1)

版本 SDK 不兼容在 android 文件夹下的 build.gradle 中检查 SDK 版本

例如

<块引用>
ext {
    buildToolsVersion = "29.0.2"
    minSdkVersion = 16
    compileSdkVersion = 29
    targetSdkVersion = 29
}

然后下载 ADV Manager

<块引用>

选择 Image API Level 29(遵循 SDK 版本)

enter image description here

答案 3 :(得分:0)

就我而言,我的 USB 出于某种原因没有连接,即使它看起来是物理连接的。我不得不更改我使用的端口。