android sdk tools: adapt path to file hierarchy changes
Recent Android SDK tools, including e.g. "8092744" and "8512546", use a different path structure than e.g. "6514223".
E.g. sdkmanager in older sdk tools used to be located at
${ANDROID_SDK_HOME}/tools/bin/sdkmanager
but now it is at
${ANDROID_SDK_HOME}/cmdline-tools/bin/sdkmanager
Related: https://github.com/kivy/python-for-android/issues/2540 https://github.com/kivy/python-for-android/pull/2593
I have tested and successfully built an apk using this PR along with the related buildozer PR (https://github.com/kivy/buildozer/pull/1511), using android sdk cli tools commandlinetools-linux-8092744_latest.zip.
Note that these paths were ~recently changed for similar reasons in https://github.com/kivy/python-for-android/pull/2593, to also search at ${ANDROID_SDK_HOME}/cmdline-tools/latest/bin/sdkmanager (note extra nesting there with latest). I don't know which version of the cli tools uses that layout. @dbnicholson
Hi @SomberNight !
From: https://developer.android.com/studio/command-line#tools-sdk
Located in: android_sdk/cmdline-tools/version/bin/
Note: The Android SDK Command-Line Tools package, located in cmdline-tools, replaces the SDK Tools package, located in tools. With the new package, you can select the version of the command line tools you want to install, and you can install multiple versions at a time. With the old package, you can only install the latest version of the tools. Thus, the new package lets you depend on specific versions of the command-line tools without having your code break when new versions are released. For information about the deprecated SDK Tools package, see the SDK Tools release notes.
And as @dbnicholson said in #2593 :
This could definitely be better by looking for other versions of cmdline-tools instead of just latest.
So, ${ANDROID_SDK_HOME}/cmdline-tools/bin/sdkmanager is not a valid path for installs, at least for Google.
I've just tried to install multiple versions (6.0 and latest) via Android Studio and that how my folder structure now looks like:
(venv) mirko@Mirkos-MacBook-Pro python-for-android % ls -l /Users/mirko/.buildozer/android/platform/android-sdk/cmdline-tools
total 0
drwxr-xr-x 7 mirko staff 224 8 Oct 14:55 6.0
drwxr-xr-x 7 mirko staff 224 8 Oct 14:52 latest
I guess we have to migrate our docs and/or automated installs instead of supporting a new (non-standard) folder structure.
So,
${ANDROID_SDK_HOME}/cmdline-tools/bin/sdkmanageris not a valid path for installs, at least for Google.
Hmm, so are we not supposed to just simply unzip the tools google hosts, but are now expected to move stuff around to have a specific layout?
I spent a while looking at this trying to figure out how to only download the command line tools once, but this is the bootstrapping procedure I came up with.
wget https://dl.google.com/android/repository/commandlinetools-$(PLATFORM)-7583922_latest.zip
rm -rf cmdline-tools
unzip commandlinetools-$(PLATFORM)-7583922_latest.zip
# This is unfortunate since it will download the command line tools
# again, but after this it will be properly installed and updatable.
yes y | ./cmdline-tools/bin/sdkmanager "cmdline-tools;latest" --sdk_root=$(SDK)
rm -rf cmdline-tools
rm commandlinetools-$(PLATFORM)-7583922_latest.zip
There's a couple make variables in there, but I think it should be pretty clear. After that $(SDK)/cmdline-tools/latest/bin/sdkmanager can be used normally without passing --sdk_root and the package is properly installed and updatable. You could obviously install a different version than latest.
I spent a while looking at this trying to figure out how to only download the command line tools once, but this is the bootstrapping procedure I came up with.
wget https://dl.google.com/android/repository/commandlinetools-$(PLATFORM)-7583922_latest.zip rm -rf cmdline-tools unzip commandlinetools-$(PLATFORM)-7583922_latest.zip # This is unfortunate since it will download the command line tools # again, but after this it will be properly installed and updatable. yes y | ./cmdline-tools/bin/sdkmanager "cmdline-tools;latest" --sdk_root=$(SDK) rm -rf cmdline-tools rm commandlinetools-$(PLATFORM)-7583922_latest.zipThere's a couple
makevariables in there, but I think it should be pretty clear. After that$(SDK)/cmdline-tools/latest/bin/sdkmanagercan be used normally without passing--sdk_rootand the package is properly installed and updatable. You could obviously install a different version thanlatest.
Yeah, downloading it twice is not something super nice, but that's definitely the cleaner approach (IMHO).