Accept licenses of Android sdkmanager via pipe

Hello everyone.

I would like to install the Android SDK Command-Line tools from the powershell. I could not find any way to pass “yes” to accept automatically the licenses for Android SDK command line tools. Here is:

echo yes | sdkmanager --sdk_root=${ANDROID_HOME} --licenses

By that, I am always prompted to type “y” or “n” in the powershell. Is it possible to pass the “yes” or “y” via the pipe?
Do you have any idea?

I also tested the following withou any success:

echo "yes" | sdkmanager --sdk_root=${ANDROID_HOME} --licenses
echo "y" | sdkmanager --sdk_root=${ANDROID_HOME} --licenses
echo y | sdkmanager --sdk_root=${ANDROID_HOME} --licenses

Regards,

Have you tried removing echo?

“y” | command

I have also tried the followings

"y" | command
'y' | command
'Y' | command
"yes" | command
'yes' | command
'Yes' | command
'YES' | command

without any success.

There is more than one license. Try this

(1..10 | ForEach-Object {"Yes"; Start-Sleep -Milliseconds 100}) | sdkmanager --sdk_root=${ANDROID_HOME} --licenses

Thank you. It works properly in the PowerShell of my Windows machine! However, if I run this command in the GitLab runner for Windows, it is not executed as it is expected. I still receive:

7 of 7 SDK package licenses not accepted.
Review licenses that have not been accepted (y/N)? 

My Windows’ PowerShell version is 5.1.19041.1682 and GitLab’s runner version is 5.1.17763.1007 (execute $host command).

I tried to delay the execution of the command playing with Start-Sleep arguments ([-Seconds], increase value for -Milliseconds and for -Duration), but without any success.

I really appreciate any ideas.

Regards