Skip to content

Instantly share code, notes, and snippets.

@alimsk
Created September 19, 2021 13:05
Show Gist options
  • Save alimsk/6b6ea2bca60190a3b441fff02bb4fc86 to your computer and use it in GitHub Desktop.
Save alimsk/6b6ea2bca60190a3b441fff02bb4fc86 to your computer and use it in GitHub Desktop.
install android sdk for flutter without android studio

assuming you are already installed flutter and jdk 8.

first download command line tools

android sdk download page

download the Command line tools only.
link:
https://developer.android.com/studio/index.html#downloads

cd into your home directory and create folder android_sdk/cmdline-tools.
extract the downloaded command line tools into the newly created folder cmdline-tools.
then rename the extracted folder to latest.

now it should be something like this:

$ ls $HOME/android_sdk/cmdline-tools/latest
bin  lib  NOTICE.txt  source.properties

add this to .bashrc file, or whatever shell you are using

export ANDROID_SDK_ROOT=$HOME/android_sdk
export PATH=$PATH:$ANDROID_SDK_ROOT/cmdline-tools/latest/bin
# prepared
export PATH=$PATH:$ANDROID_SDK_ROOT/platform-tools
export PATH=$PATH:$ANDROID_SDK_ROOT/tools
export PATH=$PATH:$ANDROID_SDK_ROOT/emulator

then, restart your terminal if it is running. or start a new terminal if not.

run the following command:

sdkmanager "platforms;android-30"
sdkmanager "patcher;v4"
sdkmanager "tools"
sdkmanager "build-tools;29.0.2"
sdkmanager --update

it will download some big files, just wait until it complete.
then run this command:

flutter config --android-sdk $ANDROID_SDK_ROOT
flutter doctor --android-licenses

it will ask something (y/n), just y all.

now try running your flutter app. good luck

Addition

if you are using scrcpy, and it doesn't work properly when running flutter,
make sure the adb version you are using is the same as the one in android sdk.

to fix it, copy the adb binary located in $ANDROID_SDK_ROOT/platform-tools (used by flutter) to /usr/bin (used by scrcpy).
for example:

sudo cp $ANDROID_SDK_ROOT/platform-tools/adb /usr/bin

References

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment