android-actions/setup-android

Feature Request: Specify SDK Version

wSedlacek opened this issue · 10 comments

const COMMANDLINE_TOOLS_VERSION = '6858069'

await callSdkManager(sdkManager, 'platform-tools')

I am in need of the Android 28-30 SDK.
It would be great if we could either specify a version to use or update the version to the latest.

✖ Cannot find a compatible Android SDK for compilation. To be able to build for Android, install Android SDK 28 or later. 
 Run `$ sdkmanager` to manage your Android SDK versions. 

✖ You need to have the Android SDK Build-tools installed on your system. You can install any version in the following range: '>=23 <=30'. 
 Run `$ sdkmanager` from your command-line to install required `Android Build Tools`. In case you already have them installed, make sure `ANDROID_HOME` environment variable is set correctly. 

Your environment is not configured properly and you will not be able to execute local builds. To continue, choose one of the following options: 
Run $ tns preview command to enjoy NativeScript without any local setup.
Run $ tns setup command to run the setup script to try to automatically configure your environment for local builds.
Verify that your environment is configured according to the system requirements described at https://docs.nativescript.org/start/general-requirements#full-setup-requirements-linux.

I was able to work around this issue by running the following command after this action.

sdkmanager "emulator" "build-tools;30.0.3" "platforms;android-30"

I believe sdkmanager "build-tools;30.0.3" "platforms;android-30" should be enough to solve your problem, you don't need to install or update emulator.

const COMMANDLINE_TOOLS_VERSION = '6858069' should be an input variable, because it refers to cmdline-tools version 3.0, while the current is 4.0 or 5.0. PRs are welcome :)

you don't need to install or update emulator.

Unfortunately the emulator is used by NativeScript to determine if the SDK is installed or not.
That can likely be solved on their side.

As far as making it easier to specify versions, how do you feel about the following interface?

- name: Setup Android SDK
  uses: android-actions/setup-android@v2
  with:
    commandline-tools-version: 6858069
    sdks: 
      - emulator
      - platforms;android-30
      - build-tools;30.0.3

Also, I have doubts that there is actual need to have an older version of sdkmanager. sdkmanager is the package manager tool, the one that install packages. emulator, platforms, build-tools and etc are packages installed by it, but not the thing itself. The errors you got before were due to the packages, not the package manager.

Updating sdkamanger to current version would be more desirable. I recall something about mac version moving from zip to dmg.

As for the packages themselves. I personally just install whatever I need right after the setup-android:

- uses: android-actions/setup-android@v2
- run: sdkmanager "ndk;23.0.7599858" "cmake;3.18.1"

But I don't mind having something like:

- name: Setup Android SDK
  uses: android-actions/setup-android@v2
  with:
    packages: 
      - build-tools;30.0.3
      - ndk;23.0.7599858
      - cmake;3.18.1

Notice I have changed sdks to packages

I have doubts that there is actual need to have an older version of sdkmanager.

I guess it would be more of a matter of maintenance. Hard coding the value requires updates in the the project to keep it current. Where as exposing the version would remove that variable.

That said because the version doesn't seem to be following semver that could be trouble with the cli arguments changing with newer versions.

That part I am flexible with just leaving hard coded if that's your preference as I don't have anything blocked by that.

Notice I have changed sdks to packages

That's a better name. Good call out.

I'll put up a PR for that change when I find some spare time.

Would it be possible to add an optional parameter to specify, and just use the latest version if it's omitted?

As for the packages themselves. I personally just install whatever I need right after the setup-android:

- uses: android-actions/setup-android@v2
- run: sdkmanager "ndk;23.0.7599858" "cmake;3.18.1"

It would be nice to have this use-case documented in the README (for beginners like myself that didn't understand the purpose of sdkmanager).

Did this go anywhere? It's a fairly useful feature in my use case. Thank you!

| [command]/root/.android/sdk/cmdline-tools/11.0/bin/sdkmanager tools
Warning: Dependant package with key emulator not found!                           
| Warning: Unable to compute a complete list of dependencies.
| Error: The process '/root/.android/sdk/cmdline-tools/11.0/bin/sdkmanager' failed with exit code 1
[Android CI/build]   ❌  Failure - Main Setup Android SDK
[Android CI/build] exitcode '1': failure

just install whatever I need right after the setup-android

the action crashes, so it's impossible to install anything in this case

The issue is probably related to build tools version but I have no idea how build tools version is reflected on command line tools version and having a hardcoded version does not help 😿

@remixer-dec , I assume you're trying to run this in arm64 runner, we're tracking that in issue #283 .

Closing this issue, because the functionality is already implemented. SDK version selection is available in v3.1.0 , package list is available in v3.2.0