Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

android sdk tools: adapt path to file hierarchy changes #2681

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

SomberNight
Copy link
Contributor

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:
#2540
#2593

Recent Android SDK tools, including e.g. "8092744" and "8512546" [1][2],
use a different path structure than e.g. "6514223" [0].
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

[0]: https://dl.google.com/android/repository/commandlinetools-linux-6514223_latest.zip
[1]: https://dl.google.com/android/repository/commandlinetools-linux-8092744_latest.zip
[2]: https://dl.google.com/android/repository/commandlinetools-linux-8512546_latest.zip

Related:
kivy#2540
kivy#2593
@SomberNight
Copy link
Contributor Author

I have tested and successfully built an apk using this PR along with the related buildozer PR (kivy/buildozer#1511), using android sdk cli tools commandlinetools-linux-8092744_latest.zip.

Note that these paths were ~recently changed for similar reasons in #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

@misl6 misl6 self-requested a review October 8, 2022 07:53
@misl6
Copy link
Member

misl6 commented Oct 8, 2022

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.

@SomberNight
Copy link
Contributor Author

So, ${ANDROID_SDK_HOME}/cmdline-tools/bin/sdkmanager is 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?

@dbnicholson
Copy link
Contributor

dbnicholson commented Oct 8, 2022

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.

@misl6
Copy link
Member

misl6 commented Oct 8, 2022

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.

Yeah, downloading it twice is not something super nice, but that's definitely the cleaner approach (IMHO).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

3 participants