Ionic capacitor run android --list cant find devices

Hello, I’m trying to run ionic capacitor run but it doesn’t find any device. Nor the emulator or physical android phone.
Running it from android studio works.

ionic capacitor run android  --list
[INFO] No native targets found.
adb devices                                                                                               
List of devices attached
R9MN3010VFJ	device
emulator-5554	device
 avdmanager list                                                                                                                                 17:21:20
Available Android Virtual Devices:
    Name: Pixel_3a_API_30_x86
  Device: pixel_3a (Google)
    Path: /home/baj/.android/avd/Pixel_3a_API_30_x86.avd
  Target: Google APIs (Google Inc.)
          Based on: Android 11.0 (R) Tag/ABI: google_apis/x86
    Skin: pixel_3a
  Sdcard: 800 MB
Available devices definitions:
id: 0 or "tv_1080p"
    Name: Android TV (1080p)
    OEM : Google
    Tag : android-tv

Might be missing something on my system ? (Linux)
Thanks

Ionic version: 6.16.1

Ionic info:

ionic info                                                                                                                              314ms  17:31:15
[WARN] Error loading @capacitor/ios package.json: Error: Cannot find module '@capacitor/ios/package'
       
       Require stack:
       - /home/baj/.npm-packages/lib/node_modules/@ionic/cli/lib/project/index.js
       - /home/baj/.npm-packages/lib/node_modules/@ionic/cli/lib/index.js
       - /home/baj/.npm-packages/lib/node_modules/@ionic/cli/index.js
       - /home/baj/.npm-packages/lib/node_modules/@ionic/cli/bin/ionic

Ionic:

   Ionic CLI       : 6.16.1 (/home/baj/.npm-packages/lib/node_modules/@ionic/cli)
   Ionic Framework : @ionic/react 5.6.8

Capacitor:

   Capacitor CLI      : 3.0.0
   @capacitor/android : 3.0.0
   @capacitor/core    : 3.0.0
   @capacitor/ios     : not installed

Utility:

   cordova-res : not installed globally
   native-run  : 1.3.0

System:

   NodeJS : v14.17.0 (/usr/bin/node)
   npm    : 7.15.1
   OS     : Linux 5.4
5 Likes

I’m having the same problem. I can see my emulator with adb devices, but can’t with ionic capacitor run android --list or npx native-run android --list.

1 Like

I have same problem, and open two issues in github Android list is not working · Issue #183 · ionic-team/native-run · GitHub and bug: npx native-run android --list is not working · Issue #4673 · ionic-team/capacitor · GitHub

I’m currently having the same problem when using capacitor run: ionic capacitor run android --list

1 Like

this was a bug in native-run, has been fixed in latest version (1.4.0)

since native-run is a dependency of @capacitor/cli, you can try to reinstall the CLI and it should pick the latest version, but make sure that was the case by checking the installed version in package-lock.json
If not updated, you can force update the dependency with npm update native-run --depth 6

3 Likes

Thank you for your response!

I have the same problem creating a new Ionic Capacitor project with:
@capacitor/cli”: “^3.0.2”,

Reinstalling and npm update native-run --depth 6 both did not work for me.

adb devices shows a device.

Tbh. I have no good idea how to approach that problem :slight_smile:
Is there anything I can do to help solve it?

1 Like

It does work with ionic cap open android
(I used android-studio-canary)

Have you tried to use ionic cap run android?

1 Like

If you are using capacitor CLI 3.0.2, it should show native-run errors now, do you see something in the terminal?

@jcesarmobile Was this issue solved? I encountered the same exact issue. I have capacitor/android - 3.1.1
ionic 6.16.3, using visual studio on a Mac. I am able to use ionic cap open android, but not ionic cap run android.

I have both emulator and plugged in android showing on adb devices, but nothing comes up still on the terminal selection.

Also tried npm update native-run --depth 6 and it is version 1.4

native-run wasn’t compatible with SDK 30, that’s what was fixed in version 1.4.0, also capacitor wasn’t showing native-run errors and that was fixed in 3.0.2.

So if you can’t run and are using those versions or newer you are hitting a different problem.

Try running npx cap run command directly instead of the ionic one and it should show the error, or ever use npx native-run command directly.

Then, if you share the errors maybe I can help you, and they usually link the native-run wiki with the common problems and how to fix them.

Hi, @jcesarmobile

I’m having the same problem.

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

But :

$ adb devices
List of devices attached
89*******       device
$ ionic info
[WARN] Error loading @capacitor/ios package.json: Error: Cannot find module '@capacitor/ios/package'

       Require stack:
       - C:\Users\AppData\Roaming\npm\node_modules\@ionic\cli\lib\project\index.js
       - C:\Users\AppData\Roaming\npm\node_modules\@ionic\cli\lib\index.js
       - C:\Users\AppData\Roaming\npm\node_modules\@ionic\cli\index.js
       - C:\Users\AppData\Roaming\npm\node_modules\@ionic\cli\bin\ionic

Ionic:

   Ionic CLI       : 6.16.2 (C:\Users\AppData\Roaming\npm\node_modules\@ionic\cli)
   Ionic Framework : @ionic/vue 5.6.12

Capacitor:

   Capacitor CLI      : 3.1.2
   @capacitor/android : 3.1.2
   @capacitor/core    : 3.1.2
   @capacitor/ios     : not installed

Utility:

   cordova-res : 0.15.3
   native-run  : 1.4.0

System:

   NodeJS : v14.17.0 (C:\Programs\nodejs\node.exe)
   npm    : 7.20.2
   OS     : Windows 10

Thanks! :wink:

can you run native-run android --list and share the result?

1 Like
$ native-run android --list
ERR_SDK_NOT_FOUND: No valid Android SDK root found.

That means the Android SDK was not found.
Did you install it?
If you did, did you create a ANDROID_SDK_ROOT environment variable pointing to the SDK folder?

1 Like

Android SDK is installed.
ANDROID_SDK_ROOT environment variable pointing to the SDK folder.

2021-08-06_12h37_11

image

Those are pointing to Android folder, should point to the SDK folder, which is inside Android folder, so you should append \sdk to them.

ANDROID_HOME is deprecated, you can remove it as you have ANDROID_SDK_ROOT

1 Like

Same issue here:

$ ionic capacitor run android -l --external
? Which device would you like to target? 
TypeError: Cannot read properties of undefined (reading 'value')

What’s the fix please?

Ionic:

   Ionic CLI                     : 6.18.1 (/home/louis/.nvm/versions/node/v16.13.0/lib/node_modules/@ionic/cli)
   Ionic Framework               : @ionic/angular 5.8.5
   @angular-devkit/build-angular : 12.1.4
   @angular-devkit/schematics    : 12.2.13
   @angular/cli                  : 12.1.4
   @ionic/angular-toolkit        : 4.0.0

Capacitor:

   Capacitor CLI      : 3.3.1
   @capacitor/android : 3.3.1
   @capacitor/core    : 3.3.1
   @capacitor/ios     : not installed

Utility:

   cordova-res : not installed globally
   native-run  : 1.5.0

System:

   NodeJS : v16.13.0 (/home/louis/.nvm/versions/node/v16.13.0/bin/node)
   npm    : 8.1.0
   OS     : Linux 5.11