Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

native-run can't find my installed SDK Platforms #244

Open
ZaLiTHkA opened this issue Aug 29, 2022 · 17 comments
Open

native-run can't find my installed SDK Platforms #244

ZaLiTHkA opened this issue Aug 29, 2022 · 17 comments
Labels

Comments

@ZaLiTHkA
Copy link

ZaLiTHkA commented Aug 29, 2022

Version:

1.6.0, installed globally from NPM

Description:

native-run never manages to locate my installed API levels, failing with ERR_UNSUITABLE_API_INSTALLATION every time.

I install both Android Studio and Android SDK using Scoop (https://github.com/ScoopInstaller/Scoop), but I've beeing doing it this way for ages and never had issues like this before.

the latest Android SDK tools are starting to require Java 11, so I install and switch JDK versions using Jabba (https://github.com/shyiko/jabba, also installed using Scoop) and I've already updated my environment variable to include the new cmdline-tools folder (with the updated sdkmanager and avdmanager tools) in my PATH variable.

I don't think I've done anything funky in my system configuration here, so is this a bug in native-run? perhaps as a result of something changing from Google's side of things?

Command Output:

running the command npx native-run android --list --verbose presents the following:

  native-run:android:utils:sdk:resolveSDKRoot Looking for $ANDROID_HOME +0ms
  native-run:android:utils:sdk:resolveSDKRoot Using $ANDROID_HOME at C:\Users\agreeff.NORTECHZA\scoop\apps\android-sdk\current +6ms
  native-run:android:utils:sdk:resolveEmulatorHome Looking for $ANDROID_EMULATOR_HOME +0ms
  native-run:android:utils:sdk:resolveEmulatorHome Looking at $HOME/.android +0ms
  native-run:android:utils:sdk:resolveEmulatorHome Using $HOME/.android/ at C:\Users\agreeff.NORTECHZA\.android +1ms
  native-run:android:utils:sdk:resolveAVDHome Looking for $ANDROID_AVD_HOME +0ms
  native-run:android:utils:sdk:resolveAVDHome Looking at $HOME/.android/avd +1ms
  native-run:android:utils:sdk:resolveAVDHome Using $HOME/.android/avd/ at C:\Users\agreeff.NORTECHZA\.android\avd +0ms
  native-run:android:utils:adb:getDevices Invoking adb with args: [ 'devices', '-l' ] +0ms
  native-run:android:utils:sdk:getSDKPackage Parsing C:\Users\agreeff.NORTECHZA\scoop\apps\android-sdk\current\platform-tools\package.xml +0ms
  native-run:android:utils:avd:getAVDINIs Discovered AVD ini files: [
  native-run:android:utils:avd:getAVDINIs   'C:\\Users\\agreeff.NORTECHZA\\.android\\avd\\Pixel_4_API_23.ini',
  native-run:android:utils:avd:getAVDINIs   'C:\\Users\\agreeff.NORTECHZA\\.android\\avd\\Pixel_4_API_30.ini',
  native-run:android:utils:avd:getAVDINIs   'C:\\Users\\agreeff.NORTECHZA\\.android\\avd\\Pixel_4_API_31.ini',
  native-run:android:utils:avd:getAVDINIs   'C:\\Users\\agreeff.NORTECHZA\\.android\\avd\\Pixel_4_API_32.ini'
  native-run:android:utils:avd:getAVDINIs ] +0ms
  native-run:android:utils:sdk:findAllSDKPackages Walking C:\Users\agreeff.NORTECHZA\scoop\apps\android-sdk\current to discover SDK packages +0ms
  native-run:android:utils:sdk:api:getAPILevels Discovered installed API Levels: [] +0ms
  native-run:android:utils:adb:parseAdbDevices Parsing adb devices from output lines: [ 'List of devices attached', '', '' ] +0ms
  native-run:android:utils:adb:getDevices Found adb devices: [] +401ms

Errors (!):

  ERR_UNSUITABLE_API_INSTALLATION: No suitable API installation found. Use --sdk-info to reveal missing packages and other issues.

        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

meanwhile, the command avdmanager list target presents the following:

Warning: Observed package id 'platforms;android-32' in inconsistent location 'C:\Users\agreeff.NORTECHZA\scoop\apps\android-sdk\current\platforms\android-32-2' (Expected 'C:\Users\agreeff.NORTECHZA\scoop\apps\android-sdk\current\platforms\android-32')
Available Android targets:==============] 100% Fetch remote repository...
----------
id: 1 or "android-30"
     Name: Android API 30
     Type: Platform
     API level: 30
     Revision: 3
----------
id: 2 or "android-31"
     Name: Android API 31
     Type: Platform
     API level: 31
     Revision: 1
----------
id: 3 or "android-32"
     Name: Android API 32
     Type: Platform
     API level: 32
     Revision: 1

ans lastly, the command sdkmanager --list_installed presents the following:

Warning: Observed package id 'platforms;android-32' in inconsistent location 'C:\Users\agreeff.NORTECHZA\scoop\apps\android-sdk\current\platforms\android-32-2' (Expected 'C:\Users\agreeff.NORTECHZA\scoop\apps\android-sdk\current\platforms\android-32')
Warning: Observed package id 'platforms;android-32' in inconsistent location 'C:\Users\agreeff.NORTECHZA\scoop\apps\android-sdk\current\platforms\android-32-2' (Expected 'C:\Users\agreeff.NORTECHZA\scoop\apps\android-sdk\current\platforms\android-32')
Installed packages:=====================] 100% Fetch remote repository...
  Path                                                  | Version | Description                                     | Location
  -------                                               | ------- | -------                                         | -------
  build-tools;30.0.3                                    | 30.0.3  | Android SDK Build-Tools 30.0.3                  | build-tools\30.0.3
  build-tools;31.0.0                                    | 31.0.0  | Android SDK Build-Tools 31                      | build-tools\31.0.0
  build-tools;32.0.0                                    | 32.0.0  | Android SDK Build-Tools 32                      | build-tools\32.0.0
  cmdline-tools;latest                                  | 7.0     | Android SDK Command-line Tools (latest)         | cmdline-tools\latest
  emulator                                              | 31.3.10 | Android Emulator                                | emulator
  extras;intel;Hardware_Accelerated_Execution_Manager   | 7.6.5   | Intel x86 Emulator Accelerator (HAXM installer) | extras\intel\Hardware_Accelerated_Execution_Manager
  patcher;v4                                            | 1       | SDK Patch Applier v4                            | patcher\v4
  platform-tools                                        | 33.0.3  | Android SDK Platform-Tools 33.0.3               | platform-tools
  platforms;android-30                                  | 3       | Android SDK Platform 30                         | platforms\android-30
  platforms;android-31                                  | 1       | Android SDK Platform 31                         | platforms\android-31
  platforms;android-32                                  | 1       | Android SDK Platform 32                         | platforms\android-32-2
  sources;android-32                                    | 1       | Sources for Android 32                          | sources\android-32
  system-images;android-22;google_apis;x86_64           | 26      | Google APIs Intel x86 Atom_64 System Image      | system-images\android-22\google_apis\x86_64
  system-images;android-23;google_apis;x86_64           | 33      | Google APIs Intel x86 Atom_64 System Image      | system-images\android-23\google_apis\x86_64
  system-images;android-24;google_apis_playstore;x86    | 19      | Google Play Intel x86 Atom System Image         | system-images\android-24\google_apis_playstore\x86
  system-images;android-25;google_apis_playstore;x86    | 9       | Google Play Intel x86 Atom System Image         | system-images\android-25\google_apis_playstore\x86
  system-images;android-26;google_apis_playstore;x86    | 7       | Google Play Intel x86 Atom System Image         | system-images\android-26\google_apis_playstore\x86
  system-images;android-27;google_apis_playstore;x86    | 3       | Google Play Intel x86 Atom System Image         | system-images\android-27\google_apis_playstore\x86
  system-images;android-28;google_apis_playstore;x86_64 | 8       | Google Play Intel x86 Atom_64 System Image      | system-images\android-28\google_apis_playstore\x86_64
  system-images;android-29;google_apis_playstore;x86_64 | 8       | Google Play Intel x86 Atom_64 System Image      | system-images\android-29\google_apis_playstore\x86_64
  system-images;android-30;google_apis_playstore;x86    | 9       | Google Play Intel x86 Atom System Image         | system-images\android-30\google_apis_playstore\x86
  system-images;android-30;google_apis_playstore;x86_64 | 10      | Google Play Intel x86 Atom_64 System Image      | system-images\android-30\google_apis_playstore\x86_64
  system-images;android-31;google_apis_playstore;x86_64 | 9       | Google Play Intel x86 Atom_64 System Image      | system-images\android-31\google_apis_playstore\x86_64
  system-images;android-32;google_apis_playstore;x86_64 | 3       | Google Play Intel x86 Atom_64 System Image      | system-images\android-32\google_apis_playstore\x86_64
  tools                                                 | 26.1.1  | Android SDK Tools 26.1.1                        | tools

SDK Info:

output of the command npx native-run --sdk-info --verbose:

  native-run:android:utils:sdk:resolveSDKRoot Looking for $ANDROID_HOME +0ms
  native-run:android:utils:sdk:resolveSDKRoot Using $ANDROID_HOME at C:\Users\agreeff.NORTECHZA\scoop\apps\android-sdk\current +4ms
  native-run:android:utils:sdk:resolveEmulatorHome Looking for $ANDROID_EMULATOR_HOME +0ms
  native-run:android:utils:sdk:resolveEmulatorHome Looking at $HOME/.android +1ms
  native-run:android:utils:sdk:resolveEmulatorHome Using $HOME/.android/ at C:\Users\agreeff.NORTECHZA\.android +0ms
  native-run:android:utils:sdk:resolveAVDHome Looking for $ANDROID_AVD_HOME +0ms
  native-run:android:utils:sdk:resolveAVDHome Looking at $HOME/.android/avd +0ms
  native-run:android:utils:sdk:resolveAVDHome Using $HOME/.android/avd/ at C:\Users\agreeff.NORTECHZA\.android\avd +1ms
  native-run:android:utils:sdk:findAllSDKPackages Walking C:\Users\agreeff.NORTECHZA\scoop\apps\android-sdk\current to discover SDK packages +0ms
  native-run:android:utils:sdk:api:getAPILevels Discovered installed API Levels: [] +0ms
SDK Location:         C:\Users\agreeff.NORTECHZA\scoop\apps\android-sdk\current
AVD Home:             C:\Users\agreeff.NORTECHZA\.android\avd


Tools:

..and no, that's not a bad copy/paste here, the Tools: section at the end is indeed completely empty.

@ZaLiTHkA
Copy link
Author

ZaLiTHkA commented Sep 6, 2022

is anybody able to shed some light on this one..? I've also just updated to [email protected], but nothing has changed.

I have checked the Android Errors wiki page, and I do indeed have the necessary SDK Platforms installed (matching both "target" and "minimum" SDK API values), along with numerous others in between.

I've also tried with only a small subset of SDK Platforms, keeping only the "target" API level, but that still made no difference.

so I'm currently stuck with ionic cordova emulate android --list (native-run.cmd android --list --virtual) throwing an error, suggesting that I "Use --sdk-info to reveal missing packages and other issues.", which still gives me absolutely zero helpful output.

what on earth is broken here...? I'm so confused.

@ZaLiTHkA ZaLiTHkA changed the title native-run can't find my installed API levels native-run can't find my installed SDK Platforms Sep 6, 2022
@ZaLiTHkA
Copy link
Author

ZaLiTHkA commented Sep 6, 2022

I think I've worked out what's going wrong here..

this is failing because scoop installs "apps" to a versioned path, then symlinks it to /current, and native-run's findAllSDKPackages method simply does not like symlinks.

I confirmed this by cloning this project, linking it globally in my dev environment, and replacing the sdk.root reference from

const contents = await readdirp(sdk.root, {
with the physical path that scoop installed my Android SDK to. this worked exactly as expected:

❯ npx native-run android --sdk-info --verbose
  native-run:android:utils:sdk:resolveSDKRoot Looking for $ANDROID_HOME +0ms
  native-run:android:utils:sdk:resolveSDKRoot Using $ANDROID_HOME at C:\Users\agreeff.NORTECHZA\scoop\apps\android-sdk\current +5ms
  native-run:android:utils:sdk:resolveEmulatorHome Looking for $ANDROID_EMULATOR_HOME +0ms
  native-run:android:utils:sdk:resolveEmulatorHome Looking at $HOME/.android +1ms
  native-run:android:utils:sdk:resolveEmulatorHome Using $HOME/.android/ at C:\Users\agreeff.NORTECHZA\.android +0ms
  native-run:android:utils:sdk:resolveAVDHome Looking for $ANDROID_AVD_HOME +0ms
  native-run:android:utils:sdk:resolveAVDHome Looking at $HOME/.android/avd +0ms
  native-run:android:utils:sdk:resolveAVDHome Using $HOME/.android/avd/ at C:\Users\agreeff.NORTECHZA\.android\avd +0ms
  native-run:android:utils:sdk:findAllSDKPackages Walking C:\Users\agreeff.NORTECHZA\scoop\apps\android-sdk\current to discover SDK packages +0ms
  native-run:android:utils:sdk:findAllSDKPackages [HACK]: ignoring "sdk.root" in favour of non-symlinked path of "C:\Users\agreeff.NORTECHZA\scoop\apps\android-sdk\4333796" +0ms
  native-run:android:utils:sdk:getSDKPackage Parsing C:\Users\agreeff.NORTECHZA\scoop\apps\android-sdk\4333796\emulator\package.xml +0ms
  native-run:android:utils:sdk:getSDKPackage Parsing C:\Users\agreeff.NORTECHZA\scoop\apps\android-sdk\4333796\platform-tools\package.xml +0ms
  native-run:android:utils:sdk:getSDKPackage Parsing C:\Users\agreeff.NORTECHZA\scoop\apps\android-sdk\4333796\tools\package.xml +0ms
  native-run:android:utils:sdk:getSDKPackage Parsing C:\Users\agreeff.NORTECHZA\scoop\apps\android-sdk\4333796\add-ons\addon-google_apis-google-22\package.xml +0ms
  native-run:android:utils:sdk:getSDKPackage Parsing C:\Users\agreeff.NORTECHZA\scoop\apps\android-sdk\4333796\add-ons\addon-google_apis-google-23\package.xml +0ms
  native-run:android:utils:sdk:getSDKPackage Parsing C:\Users\agreeff.NORTECHZA\scoop\apps\android-sdk\4333796\add-ons\addon-google_apis-google-24\package.xml +0ms
  native-run:android:utils:sdk:api:getAPILevels Discovered installed API Levels: [
  native-run:android:utils:sdk:api:getAPILevels   {
  native-run:android:utils:sdk:api:getAPILevels     apiLevel: '24',
  native-run:android:utils:sdk:api:getAPILevels     packages: [ 'add-ons;addon-google_apis-google-24' ]
  native-run:android:utils:sdk:api:getAPILevels   },
  native-run:android:utils:sdk:api:getAPILevels   {
  native-run:android:utils:sdk:api:getAPILevels     apiLevel: '23',
  native-run:android:utils:sdk:api:getAPILevels     packages: [ 'add-ons;addon-google_apis-google-23' ]
  native-run:android:utils:sdk:api:getAPILevels   },
  native-run:android:utils:sdk:api:getAPILevels   {
  native-run:android:utils:sdk:api:getAPILevels     apiLevel: '22',
  native-run:android:utils:sdk:api:getAPILevels     packages: [ 'add-ons;addon-google_apis-google-22' ]
  native-run:android:utils:sdk:api:getAPILevels   }
  native-run:android:utils:sdk:api:getAPILevels ] +0ms
SDK Location:         C:\Users\agreeff.NORTECHZA\scoop\apps\android-sdk\current
AVD Home:             C:\Users\agreeff.NORTECHZA\.android\avd

API Level:            24
Packages:             Google APIs  add-ons;addon-google_apis-google-24  1
(!) Missing Packages: Android SDK Platform 24  platforms;android-24
                      Google Play Intel x86 Atom System Image  system-images;android-24;google_apis_playstore;x86  /.+/


API Level:            23
Packages:             Google APIs  add-ons;addon-google_apis-google-23  1


API Level:            22
Packages:             Google APIs  add-ons;addon-google_apis-google-22  1


Tools:

Android Emulator  emulator  31.3.10
Android SDK Platform-Tools  platform-tools  33.0.3
Android SDK Tools 26.1.1  tools  26.1.1

pretty sure I can fix this one, so I'll get it working on my side and send a PR shortly.

ZaLiTHkA pushed a commit to ZaLiTHkA/native-run that referenced this issue Sep 6, 2022
…path`

this closes ionic-team#244, as it allows `native-run` to function as designed when various aspects of the Android SDK installation are referenced by symbolic links instead of real folder paths.
@ZaLiTHkA
Copy link
Author

ZaLiTHkA commented Sep 7, 2022

so here's an interesting one, although the PR I sent for this does work, it seems there are some other problems cropping up.. I'm not sure if this is also related to the use of symlinks though.

I highly doubt my changes here would have affected this. could I ask someone who doesn't have my "environment symlink" issues to perhaps try this one?


reading my environment SDK installation details, I only see the following output:

❯ node .\bin\native-run android --sdk-info
SDK Location:         C:\Users\agreeff.NORTECHZA\scoop\apps\android-sdk\4333796
AVD Home:             C:\Users\agreeff.NORTECHZA\.android\avd

API Level:            23
Packages:             Google APIs  add-ons;addon-google_apis-google-23  1


API Level:            22
Packages:             Google APIs  add-ons;addon-google_apis-google-22  1


Tools:

Android Emulator  emulator  31.3.10
Android SDK Platform-Tools  platform-tools  33.0.3
Android SDK Tools 26.1.1  tools  26.1.1

meanwhile...

❯ sdkmanager.bat --list_installed
Installed packages:=====================] 100% Fetch remote repository...
  Path                                                  | Version | Description                                     | Location
  -------                                               | ------- | -------                                         | -------
  add-ons;addon-google_apis-google-22                   | 1       | Google APIs                                     | add-ons\addon-google_apis-google-22
  add-ons;addon-google_apis-google-23                   | 1       | Google APIs                                     | add-ons\addon-google_apis-google-23
  build-tools;33.0.0                                    | 33.0.0  | Android SDK Build-Tools 33                      | build-tools\33.0.0
  cmdline-tools;latest                                  | 7.0     | Android SDK Command-line Tools (latest)         | cmdline-tools\latest
  emulator                                              | 31.3.10 | Android Emulator                                | emulator
  extras;intel;Hardware_Accelerated_Execution_Manager   | 7.6.5   | Intel x86 Emulator Accelerator (HAXM installer) | extras\intel\Hardware_Accelerated_Execution_Manager
  patcher;v4                                            | 1       | SDK Patch Applier v4                            | patcher\v4
  platform-tools                                        | 33.0.3  | Android SDK Platform-Tools                      | platform-tools
  platforms;android-24                                  | 2       | Android SDK Platform 24                         | platforms\android-24
  platforms;android-25                                  | 3       | Android SDK Platform 25                         | platforms\android-25
  platforms;android-26                                  | 2       | Android SDK Platform 26                         | platforms\android-26
  platforms;android-27                                  | 3       | Android SDK Platform 27                         | platforms\android-27
  platforms;android-28                                  | 6       | Android SDK Platform 28                         | platforms\android-28
  platforms;android-29                                  | 5       | Android SDK Platform 29                         | platforms\android-29
  platforms;android-30                                  | 3       | Android SDK Platform 30                         | platforms\android-30
  platforms;android-31                                  | 1       | Android SDK Platform 31                         | platforms\android-31
  platforms;android-32                                  | 1       | Android SDK Platform 32                         | platforms\android-32
  system-images;android-22;google_apis;x86_64           | 26      | Google APIs Intel x86 Atom_64 System Image      | system-images\android-22\google_apis\x86_64
  system-images;android-23;google_apis;x86_64           | 33      | Google APIs Intel x86 Atom_64 System Image      | system-images\android-23\google_apis\x86_64
  system-images;android-24;google_apis_playstore;x86    | 19      | Google Play Intel x86 Atom System Image         | system-images\android-24\google_apis_playstore\x86
  system-images;android-25;google_apis_playstore;x86    | 9       | Google Play Intel x86 Atom System Image         | system-images\android-25\google_apis_playstore\x86
  system-images;android-26;google_apis_playstore;x86    | 7       | Google Play Intel x86 Atom System Image         | system-images\android-26\google_apis_playstore\x86
  system-images;android-27;google_apis_playstore;x86    | 3       | Google Play Intel x86 Atom System Image         | system-images\android-27\google_apis_playstore\x86
  system-images;android-28;google_apis_playstore;x86_64 | 8       | Google Play Intel x86 Atom_64 System Image      | system-images\android-28\google_apis_playstore\x86_64
  system-images;android-29;google_apis_playstore;x86_64 | 8       | Google Play Intel x86 Atom_64 System Image      | system-images\android-29\google_apis_playstore\x86_64
  system-images;android-30;google_apis_playstore;x86_64 | 10      | Google Play Intel x86 Atom_64 System Image      | system-images\android-30\google_apis_playstore\x86_64
  system-images;android-31;google_apis_playstore;x86_64 | 9       | Google Play Intel x86 Atom_64 System Image      | system-images\android-31\google_apis_playstore\x86_64
  system-images;android-32;google_apis_playstore;x86_64 | 3       | Google Play Intel x86 Atom_64 System Image      | system-images\android-32\google_apis_playstore\x86_64
  tools                                                 | 26.1.1  | Android SDK Tools 26.1.1                        | tools

@ZaLiTHkA
Copy link
Author

ZaLiTHkA commented Sep 7, 2022

NOTE: I've opted to simply replace my Scoop-based installations of Android Studio and the Android SDK with those from the official installer..

I have project deadlines coming up and I don't have time right now to dig too much further into this one. I would like to come back to this when I can, because I believe it is something worth catering for.

with that said, if anybody in "Team Ionic" feel like closing this off, or taking over what I started, feel free to do so.. I'll leave this issue open for the moment.

edit: just had another thought.. perhaps I should rather close this issue in favour of a new one, collating relevant information from my investigations into the symlink handling issue, titled and structured appropriately for that task. open to suggestions.

@mklueh
Copy link

mklueh commented Dec 12, 2022

I'm trying to get started with Ionic, but so far I had no luck at all. I'm trying to get it working in WSL Ubuntu. To get the SDK, I installed Android Studio. It obviously has installed all the latest stuff by default, but I haven't read anything regarding incompatibilities of ionic with the latest SDK.

Yet I'm running into

ERR_UNSUITABLE_API_INSTALLATION: No suitable API installation found. Use --sdk-info to reveal missing packages and other issues.

This is my output of native-run android --sdk-info

SDK Location:         /home/user/Android/Sdk
AVD Home:             /home/user/.android/avd

API Level:            33
Packages:             Android SDK Platform 33  platforms;android-33  2
                      Google APIs Intel x86 Atom_64 System Image  system-images;android-33;google_apis;x86_64  7
                      Sources for Android 33  sources;android-33  1


API Level:            28
Packages:             Android SDK Platform 28  platforms;android-28  6
                      Sources for Android 28  sources;android-28  1
(!) Missing Packages: Google Play Intel x86 Atom System Image  system-images;android-28;google_apis_playstore;x86  /.+/


Tools:

Android Emulator  emulator  31.3.13
Android SDK Build-Tools 33.0.1  build-tools;33.0.1  33.0.1
Android SDK Command-line Tools (latest)  cmdline-tools;latest  8.0
Android SDK Platform-Tools  platform-tools  33.0.3
SDK Patch Applier v4  patcher;v4  1

I can't get any meaningful information out of anything that would indicate what is missing.

One thing I had to do previously, as Ionic is not compatible with Yarn Berry was patching the cli ionic-team/ionic-cli#4483 but otherwise it's a fresh installation. I'd appreciate any help

@ZaLiTHkA
Copy link
Author

@mklueh FWIW, my particular problem was caused by the symbolic links created by the Scoop installer. switching over to the "standard" ways of installing the relevant tools resolved the issue for me.

going by the SDK and AVD paths in your environment, I would hazard a guess and say that you're not using any fancy third-party installers like Scoop? could you perhaps share the output from running the ionic info or ionic doctor CLI command from your project root?

also, I highly doublt the patch you mentioned for Yarn v2 would have any influence here, that relates to installing Node packages, whereas the issue you're running into here is related to locating Android SDK resources.

take note: the "Missing Packages" CLI output for API level 28 is not an error here, it's just telling you that there are no AVD images available for that Android version, so you won't be able to create and run an Android 9 (API 28) emulator.


the ERR_UNSUITABLE_API_INSTALLATION error would come up when trying to build or run a project, so the best bet is to step into the runtime for this process..

what "target API" is your project set to use? and are you certain that you have the "Android SDK Platform " and "Sources for Android " packages installed for that version?

if you are targeting the latest API, is your current environment using JDK 11? this is required to build the Android Gradle project for anything higher than API 31 (IIRC, this changed when the "Android Gradle" plugin in the native project updated from 4.x to 7.x). I had issues with this myself, but some commands were not throwing the "unsupported major minor version" error that I would expect, so it took my a little while to work out.

@mklueh
Copy link

mklueh commented Dec 13, 2022

@ZaLiTHkA thanks for your help!

I'm not using scoop or anything. Not sure what the default jdk is that comes with Android Studio, will look that up in the evening and run the ionic info command.

But I was just trying to get the Nuxt 3 Ionic boilerplate working https://github.com/Dawntraoz/nuxt3-ionic-boilerplate

One thing I remember was, the add android command failed as the Android SDK was not installed at that time, but I tried to re-run it and it says it's already added. I already ran capacitor update

@mklueh
Copy link

mklueh commented Dec 14, 2022

ionic info

Ionic:

   Ionic CLI       : 6.20.1 (/home/user/workspace/my-app/node_modules/@ionic/cli)
   Ionic Framework : @ionic/vue 6.4.0 (/home/user/workspace/my-app/node_modules/@ionic/vue)

Capacitor:

   Capacitor CLI      : 4.6.1
   @capacitor/android : 4.6.1 (/home/user/workspace/my-app/node_modules/@capacitor/android)
   @capacitor/core    : 4.6.1 (/home/user/workspace/my-app/node_modules/@capacitor/core)
   @capacitor/ios     : 4.6.1 (/home/user/workspace/my-app/node_modules/@capacitor/ios)

Utility:

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

System:

   NodeJS : v16.18.1 (/usr/bin/node)
   npm    : 8.19.2
   OS     : Linux 5.15


  ─────────────────────────────────────────────────


ionic doctor

[WARN] For best results, please make sure you're logged in to Ionic.

       Some issues can't be detected without authentication. Run:

       ionic login
⠧ Detecting issues: 7 / 9 complete [ERROR] Error while checking viewport-fit-not-set:

        Error: ENOENT: no such file or directory, open
        '/home/user/workspace/my-app/apps/demo-mobile-app/src/index.html'
✔ Detecting issues: 9 / 9 complete in 14.22ms
[WARN] The Ionic CLI is installed locally.

       While the CLI can run locally, there's no longer a reason to have it installed locally and it may cause some
       confusion over configuration and versions.

       To fix, the following step(s) need to be taken:

       1) Run: yarn remove @ionic/cli

       $ ionic config set -g doctor.issues.ionic-installed-locally.ignored true (ignore this issue in the future)
       $ ionic doctor treat ionic-installed-locally (attempt to fix this issue)

[WARN] Git doesn't appear to be in use.

       We highly recommend using source control software such as git (https://git-scm.com) to track changes in your code
       throughout time.

       To fix, take the following step(s):

       1) Download git if you don't have it installed: https://git-scm.com/downloads
       2) Learn the basics if you're unfamiliar with git: https://try.github.io
       3) Make your first commit and start tracking code changes! 😍

       $ ionic config set -g doctor.issues.git-not-used.ignored true (ignore this issue in the future)

[INFO] Doctor Summary

       - Detected 2 issues.
       - 1 issue can be fixed automatically by running: ionic doctor fix
user@DESKTOP-MYPC:~/workspace/my-app/apps/demo-mobile-app$ sudo apt-get install git
[sudo] password for user: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
git is already the newest version (1:2.25.1-1ubuntu3.6).
0 upgraded, 0 newly installed, 0 to remove and 1 not upgraded.
user@DESKTOP-MYPC:~/workspace/my-app/apps/demo-mobile-app$ 

"git not installed" is a false flag and the missing index.html will be generated in the dist directory during build. The ionic/cli is installed locally, otherwise I can't use the patch to make it working with yarn berry. I also doubt it has any impact, other than the latest CLI version is not used :)

@ZaLiTHkA
Copy link
Author

I'm not using scoop or anything. Not sure what the default jdk is that comes with Android Studio, will look that up in the evening and run the ionic info command.

if you have a current release, that should be JDK 11.. but keep in mind that won't become your "system default" by itself, that part depends on your current environment variables. I would suggest you verify the current version with javac -version.

FWIW, if you're not already using one, perhaps a Java "version manager" might be helpful? SDKMAN!, Jabba, and jenv are all pretty good. they do make JDK management a little less tedious.

One thing I remember was, the add android command failed as the Android SDK was not installed at that time, but I tried to re-run it and it says it's already added. I already ran capacitor update

Capacitor CLI only checks for the existence of the android folder in your project.. if it's there, then it will complain that the platform already exists. to re-generate a native platform project (aka: cap add), you do quite literally have to delete the previously generated native project folder..

"git not installed" is a false flag and the missing index.html will be generated in the dist directory during build. The ionic/cli is installed locally, otherwise I can't use the patch to make it working with yarn berry. I also doubt it has any impact, other than the latest CLI version is not used :)

I don't see any of that being an issue.. that message regarding Git usage is more likely because the current project (being a "test") might not be initialised as a Git repo. the message regarding a local Ionic CLI installation is also not as uncommon as you would think, I need to do that to use Ionic in Nx workspaces. installed package versions also look fine, not the latest latest, but sometimes that's a little safer anyway (at your own discretion, Ionic's changelogs are your best friend here).

I must say that I haven't made the jump to Yarn v2 yet, not sure if there is anything there that may be affecting this...


with all that said, I'm still not unsure of what the issue is in your environment.. 🤔 but I do know that the majority of these CLI tools depend heavily on environment variables, so just to confirm, do the following variables exist in your environment at runtime when you execute your CLI commands?

  • ANDROID_HOME and ANDROID_SDK_ROOT - save yourself the headaches and just set both, not all third-party tools look at the newer variable name yet..
  • JAVA_HOME - personally, I use the Android Studio JDK 11 path in my user environment, then use Jabba (..on Windows.. 🤢) to switch to a custom version when I need.

lastly, ensure the following paths exist in your current environment's PATH variable:

  • $JAVA_HOME/bin
  • $ANDROID_HOME/emulator
  • $ANDROID_HOME/cmdline-tools/latest/bin
  • $ANDROID_HOME/platform-tools

I suspect you might find something missing or misconfigured in this area somewhere.. please let me know if that helps at all?

@mklueh
Copy link

mklueh commented Dec 14, 2022

I'm not using scoop or anything. Not sure what the default jdk is that comes with Android Studio, will look that up in the evening and run the ionic info command.

if you have a current release, that should be JDK 11.. but keep in mind that won't become your "system default" by itself, that part depends on your current environment variables. I would suggest you verify the current version with javac -version.

I'm currently going with OpenJDK 16, so that should not be the problem.

FWIW, if you're not already using one, perhaps a Java "version manager" might be helpful? SDKMAN!, Jabba, and jenv are all pretty good. they do make JDK management a little less tedious.

Thank you, I didn't know that and will check it out.

One thing I remember was, the add android command failed as the Android SDK was not installed at that time, but I tried to re-run it and it says it's already added. I already ran capacitor update

Capacitor CLI only checks for the existence of the android folder in your project.. if it's there, then it will complain that the platform already exists. to re-generate a native platform project (aka: cap add), you do quite literally have to delete the previously generated native project folder..

Got it. I've also deleted it and re-created it with no impact.

"git not installed" is a false flag and the missing index.html will be generated in the dist directory during build. The ionic/cli is installed locally, otherwise I can't use the patch to make it working with yarn berry. I also doubt it has any impact, other than the latest CLI version is not used :)

I don't see any of that being an issue.. that message regarding Git usage is more likely because the current project (being a "test") might not be initialised as a Git repo. the message regarding a local Ionic CLI installation is also not as uncommon as you would think, I need to do that to use Ionic in Nx workspaces. installed package versions also look fine, not the latest latest, but sometimes that's a little safer anyway (at your own discretion, Ionic's changelogs are your best friend here).

I'm also running that project in an Nx workspace btw ;) But does that really mean you can't use a global installation?

I must say that I haven't made the jump to Yarn v2 yet, not sure if there is anything there that may be affecting this...

Not sure either. Would npx cap run android even interfere with Yarn?

with all that said, I'm still not unsure of what the issue is in your environment.. 🤔 but I do know that the majority of these CLI tools depend heavily on environment variables, so just to confirm, do the following variables exist in your environment at runtime when you execute your CLI commands?

  • ANDROID_HOME and ANDROID_SDK_ROOT - save yourself the headaches and just set both, not all third-party tools look at the newer variable name yet..
  • JAVA_HOME - personally, I use the Android Studio JDK 11 path in my user environment, then use Jabba (..on Windows.. 🤢) to switch to a custom version when I need.

ANDROID_HOME did not exist, but I've created it and tested it again with no impact.

lastly, ensure the following paths exist in your current environment's PATH variable:

  • $JAVA_HOME/bin
  • $ANDROID_HOME/emulator
  • $ANDROID_HOME/cmdline-tools/latest/bin
  • $ANDROID_HOME/platform-tools

I suspect you might find something missing or misconfigured in this area somewhere.. please let me know if that helps at all?

I'm missing this one indeed: $ANDROID_HOME/cmdline-tools/latest/bin but I haven't found it in the docs, but those instead

export ANDROID_SDK_ROOT=$HOME/Android/Sdk
export PATH=$PATH:$ANDROID_SDK_ROOT/tools/bin
export PATH=$PATH:$ANDROID_SDK_ROOT/platform-tools
export PATH=$PATH:$ANDROID_SDK_ROOT/emulator

https://ionicframework.com/docs/developing/android

I wish ionic/cli would just give some more details on what is missing

@mklueh
Copy link

mklueh commented Dec 27, 2022

I could solve it 😊 the reason was a missing emulator, or in my case a not startable emulator. I had to give user permissions to /dev/kvm.

Had I tried the build command instead of the run command, it probably would have worked the whole time.

@markemer
Copy link
Member

markemer commented Mar 6, 2023

@ZaLiTHkA is this still an issue - I know you moved off scoop - but it's not handling symlinks correctly on windows? Is that the issue? Or is it symlinks in general?

@pencilcheck
Copy link

pencilcheck commented Apr 16, 2023

native-run just can't detect installed API levels when I can easily run and compile in Android Studio and also checked and installed SDK properly. This is definitely a bug.

  native-run:android:utils:sdk:resolveSDKRoot Looking for $ANDROID_HOME +0ms
  native-run:android:utils:sdk:resolveSDKRoot Looking for $ANDROID_SDK_ROOT +3ms
  native-run:android:utils:sdk:resolveSDKRoot Using $ANDROID_SDK_ROOT at /usr/local/Cellar/android-sdk/24 +1ms
  native-run:android:utils:sdk:resolveEmulatorHome Looking for $ANDROID_EMULATOR_HOME +0ms
  native-run:android:utils:sdk:resolveEmulatorHome Looking at $HOME/.android +0ms
  native-run:android:utils:sdk:resolveEmulatorHome Using $HOME/.android/ at /Users/penn/.android +1ms
  native-run:android:utils:sdk:resolveAVDHome Looking for $ANDROID_AVD_HOME +0ms
  native-run:android:utils:sdk:resolveAVDHome Looking at $HOME/.android/avd +0ms
  native-run:android:utils:sdk:resolveAVDHome Using $HOME/.android/avd/ at /Users/penn/.android/avd +0ms
  native-run:android:utils:sdk:findAllSDKPackages Walking /usr/local/Cellar/android-sdk/24 to discover SDK packages +0ms
  native-run:android:utils:sdk:getSDKPackage Parsing /usr/local/Cellar/android-sdk/24/emulator/package.xml +0ms
  native-run:android:utils:sdk:getSDKPackage Parsing /usr/local/Cellar/android-sdk/24/platform-tools/package.xml +0ms
  native-run:android:utils:sdk:getSDKPackage Parsing /usr/local/Cellar/android-sdk/24/tools/package.xml +0ms
  native-run:android:utils:sdk:getSDKPackage Parsing /usr/local/Cellar/android-sdk/24/build-tools/30.0.2/package.xml +0ms
  native-run:android:utils:sdk:getSDKPackage Parsing /usr/local/Cellar/android-sdk/24/build-tools/34.0.0-rc3/package.xml +0ms
  native-run:android:utils:sdk:getSDKPackage Parsing /usr/local/Cellar/android-sdk/24/cmdline-tools/latest/package.xml +0ms
  native-run:android:utils:sdk:getSDKPackage Parsing /usr/local/Cellar/android-sdk/24/patcher/v4/package.xml +0ms
  native-run:android:utils:sdk:api:getAPILevels Discovered installed API Levels: [] +0ms
SDK Location:         /usr/local/Cellar/android-sdk/24
AVD Home:             /Users/pencilcheck/.android/avd


Tools:

Android Emulator  emulator  32.1.12
Android SDK Build-Tools 30.0.2  build-tools;30.0.2  30.0.2
Android SDK Build-Tools 34-rc3  build-tools;34.0.0-rc3  34.0.0
Android SDK Command-line Tools (latest)  cmdline-tools;latest  9.0
Android SDK Platform-Tools  platform-tools  34.0.1
Android SDK Tools  tools  26.1.1
SDK Patch Applier v4  patcher;v4  1

@xlinxie
Copy link

xlinxie commented Jun 18, 2023

native-run just can't detect installed API levels when I can easily run and compile in Android Studio and also checked and installed SDK properly. This is definitely a bug.

  native-run:android:utils:sdk:resolveSDKRoot Looking for $ANDROID_HOME +0ms
  native-run:android:utils:sdk:resolveSDKRoot Looking for $ANDROID_SDK_ROOT +3ms
  native-run:android:utils:sdk:resolveSDKRoot Using $ANDROID_SDK_ROOT at /usr/local/Cellar/android-sdk/24 +1ms
  native-run:android:utils:sdk:resolveEmulatorHome Looking for $ANDROID_EMULATOR_HOME +0ms
  native-run:android:utils:sdk:resolveEmulatorHome Looking at $HOME/.android +0ms
  native-run:android:utils:sdk:resolveEmulatorHome Using $HOME/.android/ at /Users/penn/.android +1ms
  native-run:android:utils:sdk:resolveAVDHome Looking for $ANDROID_AVD_HOME +0ms
  native-run:android:utils:sdk:resolveAVDHome Looking at $HOME/.android/avd +0ms
  native-run:android:utils:sdk:resolveAVDHome Using $HOME/.android/avd/ at /Users/penn/.android/avd +0ms
  native-run:android:utils:sdk:findAllSDKPackages Walking /usr/local/Cellar/android-sdk/24 to discover SDK packages +0ms
  native-run:android:utils:sdk:getSDKPackage Parsing /usr/local/Cellar/android-sdk/24/emulator/package.xml +0ms
  native-run:android:utils:sdk:getSDKPackage Parsing /usr/local/Cellar/android-sdk/24/platform-tools/package.xml +0ms
  native-run:android:utils:sdk:getSDKPackage Parsing /usr/local/Cellar/android-sdk/24/tools/package.xml +0ms
  native-run:android:utils:sdk:getSDKPackage Parsing /usr/local/Cellar/android-sdk/24/build-tools/30.0.2/package.xml +0ms
  native-run:android:utils:sdk:getSDKPackage Parsing /usr/local/Cellar/android-sdk/24/build-tools/34.0.0-rc3/package.xml +0ms
  native-run:android:utils:sdk:getSDKPackage Parsing /usr/local/Cellar/android-sdk/24/cmdline-tools/latest/package.xml +0ms
  native-run:android:utils:sdk:getSDKPackage Parsing /usr/local/Cellar/android-sdk/24/patcher/v4/package.xml +0ms
  native-run:android:utils:sdk:api:getAPILevels Discovered installed API Levels: [] +0ms
SDK Location:         /usr/local/Cellar/android-sdk/24
AVD Home:             /Users/pencilcheck/.android/avd


Tools:

Android Emulator  emulator  32.1.12
Android SDK Build-Tools 30.0.2  build-tools;30.0.2  30.0.2
Android SDK Build-Tools 34-rc3  build-tools;34.0.0-rc3  34.0.0
Android SDK Command-line Tools (latest)  cmdline-tools;latest  9.0
Android SDK Platform-Tools  platform-tools  34.0.1
Android SDK Tools  tools  26.1.1
SDK Patch Applier v4  patcher;v4  1

Please check if the platforms, sources and system-images folder exists in /usr/local/Cellar/android-sdk/24/, native-run will parse SDK package data from a package.xml file that lies in these folders, such as

  • system-images\android-30\default\arm64-v8a\package.xml
  • system-images\android-33\google_apis\x86_64\package.xml

it seems that native-run did not find these files so discovered none installed API Levels.

@rochecompaan
Copy link

I experienced the same result in a Nix shell environment that symlinks to system images. find $ANDROID_HOME/system-images/ -name "package.xml" returns no results, but adding -follow finds the package.xml files:

$ find $ANDROID_HOME/system-images/ -name "package.xml" -follow
/nix/store/1jmhkdldqc8mvjxqc35r0fv5zf9kp4h7-androidsdk/libexec/android-sdk/system-images/android-28/google_apis_playstore/arm64-v8a/package.xml
/nix/store/1jmhkdldqc8mvjxqc35r0fv5zf9kp4h7-androidsdk/libexec/android-sdk/system-images/android-29/google_apis_playstore/arm64-v8a/package.xml
/nix/store/1jmhkdldqc8mvjxqc35r0fv5zf9kp4h7-androidsdk/libexec/android-sdk/system-images/android-30/google_apis_playstore/arm64-v8a/package.xml

It suggests to me that the code to walk the tree to find package.xml files does not follow symlinks. I can share the shell.nix file if you would like to test in a reproducible environment.

@itelmenko
Copy link

Hello

I get error without ERR_* or description:


 npx cap run android --verbose

✔ Copying web assets from dist to android/app/src/main/assets/public in 13.89ms
✔ Creating capacitor.config.json in android/app/src/main/assets in 1.94ms
[info] Inlining sourcemaps
✔ copy android in 37.22ms
✔ Updating Android plugins in 5.37ms
[info] Found 4 Capacitor plugins for android:
       @capacitor/[email protected]
       @capacitor/[email protected]
       @capacitor/[email protected]
       @capacitor/[email protected]
✔ update android in 82.89ms
[error] native-run failed with error
        
        
        
        More details for this error may be available online:
        https://github.com/ionic-team/native-run/wiki/Android-Errors
        

It is Ubuntu 22.04.4 LTS

I have tried install with apt install and also with span install https://stackoverflow.com/questions/34556884/how-to-install-android-sdk-on-ubuntu

But it does not work. And I don't have idea what to do

@ZaLiTHkA
Copy link
Author

I have tried install with apt install and also with span install stackoverflow.com/questions/34556884/how-to-install-android-sdk-on-ubuntu

But it does not work. And I don't have idea what to do

by this do you mean you can't get the Android SDK configured? that's what the SO question you linked to is trying to solve. with that said, you might want to just install Android Studio and let that configure the SDK and your environment for you.

if you do already have Android Studio (or just the SDK) correctly configured, do you also have the NPM native-run package installed? you can confirm this with either which native-run or native-run --version.

if that doesn't help, then I would suggest you create a new issue and describe what you've tried so far..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants