In the past we have seen some tickets from developers building Android projects encountering an issue that leads them to believe that cmdline-tools is missing from our stacks. The error for this will likely look like this:
Cannot run program "/usr/local/share/android-sdk/cmdline-tools/latest/bin/sdkmanager": error=2, No such file or directory
After checking our stacks running a script like sdkmanager --list we can confirm that cmdline-tools are installed, the issue instead was that the command that is failing to run the program fails due to the path it is trying to use.
The command is trying this path:
/usr/local/share/android-sdk/cmdline-tools/latest/bin/sdkmanager
The path in our stacks for sdk manager is the following:
/usr/local/share/android-sdk/cmdline-tools/cmdline-tools/bin/sdkmanager
By understanding this, you can create a symlink with the following script:
mkdir /usr/local/share/android-sdk/cmdline-tools/latest/
mkdir /usr/local/share/android-sdk/cmdline-tools/latest/bin/
ln -s /usr/local/share/android-sdk/cmdline-tools/cmdline-tools/bin/sdkmanager /usr/local/share/android-sdk/cmdline-tools/latest/bin/sdkmanager
/usr/local/share/android-sdk/cmdline-tools/latest/bin/sdkmanager --licenses
Your symlink should now allow for the program to run on the correct path and cmdline-tools will be found 🙌