Accept licenses of Android sdkmanager in a Windows runner

Hello everyone.

I have created a .gitlab-ci.yml to create an .apk file by installing and using the Android SDK Command-Line Tools in a Windows runner. Unfortunately, I could not find any way to pass “yes” to accept the licenses for Android SDK command line tools. I created the .yml following the Android template which is based on linux runner.

Specifically,

#Declare windows runner
.shared_windows_runners:
  tags:
  - shared-windows
  - windows
  - windows-1809

and the sdkmanager --licenses section:

- echo yes | sdkmanager --sdk_root=${ANDROID_HOME} --licenses
- echo yes | sdkmanager --sdk_root=${ANDROID_HOME} "platforms;android-${ANDROID_COMPILE_SDK}"
- echo yes | sdkmanager --sdk_root=${ANDROID_HOME} "platform-tools"
- echo yes | sdkmanager --sdk_root=${ANDROID_HOME} "build-tools;${ANDROID_BUILD_TOOLS}"

When I execute the .yml, I receive the following respectively for each command:

$ echo yes | sdkmanager --sdk_root=${ANDROID_HOME} --licenses
7 of 7 SDK package licenses not accepted.
Review licenses that have not been accepted (y/N)? 
$ echo yes | sdkmanager --sdk_root=${ANDROID_HOME} "platforms;android-${ANDROID_COMPILE_SDK}"
............
Accept? (y/N): Skipping following packages as the license is not accepted:
Android SDK Platform 32
The following packages can not be installed since their licenses or those of the packages they depend on were not accepted:
  platforms;android-32
$ echo yes | sdkmanager --sdk_root=${ANDROID_HOME} "platform-tools"
.........................
Accept? (y/N): Skipping following packages as the license is not accepted:
Android SDK Platform-Tools
The following packages can not be installed since their licenses or those of the packages they depend on were not accepted:
  platform-tools
$ echo yes | sdkmanager --sdk_root=${ANDROID_HOME} "build-tools;${ANDROID_BUILD_TOOLS}"
.........................
Accept? (y/N): Skipping following packages as the license is not accepted:
Android SDK Build-Tools 32
The following packages can not be installed since their licenses or those of the packages they depend on were not accepted:
  build-tools;32.0.0

which is reasonable since the “yes” cannot be passed.

I also tried the followings:

- echo "yes" | sdkmanager --sdk_root=${ANDROID_HOME} --licenses
- echo "y" | sdkmanager --sdk_root=${ANDROID_HOME} --licenses
- create batch file:  cmd.exe /c"test.bat " , where test.bat contains sdkmanager --sdk_root=${ANDROID_HOME} --licenses
- cmd.exe /C" echo 'y' | sdkmanager --sdk_root=${ANDROID_HOME} --licenses"
- cmd.exe /C" echo 'yes' | sdkmanager --sdk_root=${ANDROID_HOME} --licenses"
- cmd.exe /C" echo yes | sdkmanager --sdk_root=${ANDROID_HOME} --licenses"

I run this script also from PowerShell but it always prompt me to type “yes” or “no” to accept the licenses. It seems that the pipe (“|”) is not considered at all.

On the other hand, the “yes” is passed and the installation takes place successfully in a GitLab linux runner.

Regards,