简体   繁体   中英

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

  • It is using MTP as the Device file manager

  • 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:

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:

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:

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

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:

  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).
  2. Unauthorized : Appears when you didn't accept the debug authorization of your phone.
  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".

In summary you should run this code:

  1. Enable Debug mode on your Android device. Also enable USB debug that is in the same configuration view.
  2. Run adb devices , Authorize to connect with the computer. Solve the issues( if there's any ) already commented above.
  3. Run ionic cordova run android --device .
  4. Happy coding time..

HI

I'm having the same problem.
I can solve this with this: 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
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.

In my case i do this

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM