简体   繁体   English

尝试使用离子 cordova 运行 android --device 时未找到设备/模拟器

[英]no devices/emulators found when trying to use ionic cordova run android --device

The Connected Device:连接的设备:

  • It is running Developer Options with USB debugging enabled它正在运行开发人员选项并启用 USB 调试

  • It is using MTP as the Device file manager它使用 MTP 作为设备文件管理器

  • Drivers have been installed to the laptop with no issues and I can browse the files fine驱动程序已安装到笔记本电脑上,没有任何问题,我可以正常浏览文件

When I run: ionic cordova run android --device I get this output:当我运行: ionic cordova run android --device我得到这个 output:

BUILD SUCCESSFUL in 5s
42 actionable tasks: 42 up-to-date
Built the following apk(s):
    C:\Users\K-PC\myApp\platforms\android\app\build\outputs\apk\debug\app-debug.apk
native-run.cmd android --app platforms\android\app\build\outputs\apk\debug\app-debug.apk --device
[native-run] ERR_NO_DEVICE: No hardware devices found. Not attempting emulator because --device was specified.
[native-run]
[native-run]    More details for this error may be available online:
[native-run]
[native-run]    https://github.com/ionic-team/native-run/wiki/Android-Errors
[ERROR] An error occurred while running subprocess native-run.

        native-run.cmd android --app platforms\android\app\build\outputs\apk\debug\app-d... exited with exit code 1.

        Re-running this command with the --verbose flag may provide more information.

I checked to see if the device was listed using native-run android --list and I get this output:我检查了设备是否使用native-run android --list列出,我得到了这个 output:

Errors (!):

  ERR_UNSUITABLE_API_INSTALLATION: No suitable API installation found.

        More details for this error may be available online:

        https://github.com/ionic-team/native-run/wiki/Android-Errors

Connected Devices:

  No connected devices found

Virtual Devices:

  No virtual devices found

I have Android Studio installed, I have two virtual devices in my AVD manager:我安装了 Android Studio,我的 AVD 管理器中有两个虚拟设备:

AVD 管理器

I want to deploy the APK onto the device connected to my laptop, not these emulators but its strange to see that it hasn't even recognised the emulators inside my AVD manager我想将 APK 部署到连接到我的笔记本电脑的设备上,而不是这些模拟器,但奇怪的是它甚至没有识别我的 AVD 管理器中的模拟器

How can I fix this issue?我该如何解决这个问题? I hope I have given enough detail.我希望我已经提供了足够的细节。

Using ADB使用亚行

adb devices

That command should give you a list of the attached devices.该命令应该为您提供连接设备的列表。 You must accept the debug mode on the phone.您必须接受手机上的调试模式。 Before trying to run the app with a hardware device you should check that adb has a connection with one device atleast.Some issues may appear like:在尝试使用硬件设备运行应用程序之前,您应该检查adb是否至少与一台设备连接。一些问题可能如下所示:

  1. List of devices are empty : That means that the device is either not properly connected or there's an issue with the USB cable(may be broken).设备列表为空:这意味着设备未正确连接或 USB 电缆存在问题(可能已损坏)。
  2. Unauthorized : Appears when you didn't accept the debug authorization of your phone. Unauthorized :未接受手机调试授权时出现。
  3. Offline : The phone has a little service called daemon that allows it to connect with the computer so can transfer the files and listen to changes.离线:手机有一个叫做守护进程的小服务,它允许它与计算机连接,以便传输文件并听取更改。 When this service is not running it stops the connection with the computer.当此服务未运行时,它会停止与计算机的连接。 Can be solved by rebooting the device or connect/disconnect the USB cable until it can be shown as "online".可以通过重新启动设备或连接/断开 USB 电缆来解决,直到它可以显示为“在线”。

In summary you should run this code:总之,您应该运行以下代码:

  1. Enable Debug mode on your Android device.在 Android 设备上启用调试模式。 Also enable USB debug that is in the same configuration view.还要启用在同一配置视图中的 USB 调试。
  2. Run adb devices , Authorize to connect with the computer.运行adb devices ,授权与电脑连接。 Solve the issues( if there's any ) already commented above.解决上面已经评论过的问题(如果有的话)。
  3. Run ionic cordova run android --device .运行ionic cordova run android --device
  4. Happy coding time..快乐的编码时间..

HI你好

I'm having the same problem.我有同样的问题。
I can solve this with this: Ionic forum .我可以用这个解决这个问题: Ionic forum

In the case that the command adb devices return a list of devices and emulators, but the command ionic cap run android --list not recognize these, the problem could be that required environment vars ANDROID_SDK_ROOT and ANDROID_HOME are not set.如果命令adb devices返回设备和模拟器列表,但命令ionic cap run android --list无法识别这些,问题可能是所需的环境变量ANDROID_SDK_ROOTANDROID_HOME未设置。

$ adb devices
List of devices attached
817460470221    device
emulator-5554   device

$ ionic cap run android --list
[INFO] No native targets found.

To set this vars first found the android sdk location, for this you can go to android-studio and in the menu Tools > SDK Manager , search the section call Android Location , export both vars in the shell instance used to run the ionic commands. To set this vars first found the android sdk location, for this you can go to android-studio and in the menu Tools > SDK Manager , search the section call Android Location , export both vars in the shell instance used to run the ionic commands.

In my case i do this就我而言,我这样做

export ANDROID_SDK_ROOT="/home/myhome/Android/Sdk"
export ANDROID_HOME="/myhome/myhome/Android/Sdk"  

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 没有指定目标,也没有找到设备,在运行Cordova时部署到模拟器在Mac上运行Android到Android设备 - No target specified and no devices found, deploying to emulator on running Cordova run android on Mac to an Android device 尝试在Android设备上运行Cordova应用程序时出错 - Error When Trying To Run A Cordova Application On An Android Device 尝试运行“ionic cordova run --emulator”时,在 com.android.prefs.AndroidLocation.getAvdFolder() 上出现 NoSuchMethodError 异常 - Getting NoSuchMethodError exception on com.android.prefs.AndroidLocation.getAvdFolder() when trying to run “ionic cordova run --emulator” 错误:尝试运行离子时出现未知标志“p” cordova 运行 android - Error: unknown flag `p' when trying to run ionic cordova run android 'adb devices' 找到我的 usb 设备,但 android 工作室没有。 只显示“加载设备”,运行时也说“没有找到目标设备” - 'adb devices' find my usb device,but android studio not. only show "Loading Devices", also say when run "no target device found" 离子Cordova运行android --device成功,但应用程序未在手机上显示 - ionic cordova run android --device successful but app not showing on phone 无法在设备上运行cordova应用程序或模拟器错误运行 - cannot run cordova application on device or emulators error running Ionic - 尝试在设备上运行时出现错误“未找到本机目标” - Ionic - Error "no native targets found" showing up when trying to run on the device 尝试Cordova运行Android时出现错误消息 - Error message when trying to cordova run android 用于特定设备的 Android 仿真器 - Android Emulators for Specific Devices
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM