Reputation: 1143
I am having the damnedest time getting Flutter to find the SDK command-line tools. I am trying to install the latter by downloading the zip provided at that link and unpacking it in say ${HOME}/Android
. This produces a tools
directory, and if I run the executable
${HOME}/Android/tools/bin/sdkmanager
directly (whith any number of options, etc.) I always get an error as documented in this other post. The solution recommended there actually works: move the tools
directory further down the tree to get the path
${HOME}/Android/cmdline-tools/tools/bin/sdkmanager
That new intermediate directory must be named cmdline-tools
though; I've tried other things (Sdk
, sdk_manager
, etc.) to no effect: the same errors occur.
Now, poking around in the cloned Flutter repo, I see in the file dev/bots/download_android_sdk.sh
that I'm supposed to have the executable
$ANDROID_SDK_ROOT/tools/bin/sdkmanager
This tips me off that in my setup I need
ANDROID_SDK_ROOT=${HOME}/Android/cmdline-tools
exporting that and running a bunch of sdkmanager
installation commands (like say
$ANDROID_SDK_ROOT/tools/bin/sdkmanager platform-tools
and the like) I see that my ${HOME}/Android
directory is starting to get populated with the corresponding directories platform-tools
, build-tools
, etc. So those newly-installed directories live at the same level as my $ANDROID_SDK_ROOT
which remember, as I'm doing this, is set to $HOME/Android/cmdline-tools
.
On the other hand though, when I then go look (in the same Flutter repo) in the file
packages/flutter_tools/lib/src/android/android_sdk.dart
I see that I'm supposed to have the directory $ANDROID_SDK_ROOT/build-tools
. This is in direct contradiction with the previous observation that build-tools
and the like are supposed to be at the same level as $ANDROID_SDK_ROOT
, and not under it.
My problem is I don't know how to square this apparent self-contradiction in the Flutter codebase. Which is it? In my setup, is ANDROID_SDK_ROOT
supposed to be $HOME/Android
or $HOME/Android/cmdline-tools
?
PS
I understand that $ANDROID_SDK_ROOT
is supposed to be "the SDK installation directory", but in this context this tells me nothing: after all, installing SDK
is precisely what I'm trying to do.
Upvotes: 1
Views: 151
Reputation: 21661
You got a couple comments on GitHub as well, but just be aware that the files in the dev/
folder in the Flutter repository are mainly intended for CI purposes and for people who are developing the Flutter framework itself.
The scripts you're pointing out are actually stale files that used to help set up some tests we ran on CI. We now set those tests up differently, but forgot to delete the files - so thanks for pointing this out, they're soon to be gone!
The best way to set up your Android SDK is by following the instructions at the Android Studio site. You can either use Studio to do it, or just download the SDK bundle(s) themselves.
Upvotes: 1