Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jramiresbrito/0379f19e4a56948727f2ed531f06ee1a to your computer and use it in GitHub Desktop.
Save jramiresbrito/0379f19e4a56948727f2ed531f06ee1a to your computer and use it in GitHub Desktop.

Install Android SDK CLI Ubuntu 20.04 WSL2 (Work in Progress)

Install Java 8

sudo apt update

sudo apt install openjdk-8-jdk-headless

Android SDK

wget https://dl.google.com/android/repository/commandlinetools-linux-7302050_latest.zip
mkdir -p Android/cmdline-tools
unzip commandlinetools-linux-7302050_latest.zip -d Android/cmdline-tools
mv Android/cmdline-tools/cmdline-tools Android/cmdline-tools/latest

export ANDROID_HOME=$HOME/Android
# Make sure emulator path comes before tools. Had trouble on Ubuntu with emulator from /tools being loaded
# instead of the one from /emulator
export PATH="$ANDROID_HOME/emulator:$ANDROID_HOME/tools:$ANDROID_HOME/tools/bin:$ANDROID_HOME/cmdline-tools/latest:$ANDROID_HOME/cmdline-tools/latest/bin:$ANDROID_HOME/platform-tools:$PATH"

# don't need this anymore
# sdkmanager --sdk_root=${ANDROID_HOME} "tools"

sdkmanager --update
sdkmanager --list
# find current version
sdkmanager --list | grep build-tools
sdkmanager "build-tools;30.0.3" "platform-tools" "platforms;android-30" "tools"
sdkmanager --licenses

sudo apt install gradle

Note: you can get an updated Android SDK link from https://developer.android.com/studio/#downloads

Used a combinaton of these gists: https://gist.github.com/fedme/fd42caec2e5a7e93e12943376373b7d0 https://gist.github.com/jjvillavicencio/18feb09f0e93e017a861678bc638dcb0

Background on the update to command line tools from android sdk https://stackoverflow.com/a/61176718

https://stackoverflow.com/questions/65262340/cmdline-tools-could-not-determine-sdk-root

@jramiresbrito
Copy link
Author

jramiresbrito commented Nov 21, 2021

To connect to a physical device. Connect the device to a USB Port, in your windows cmd run adb tcpip 5555. Then in your WSL cmd run adb connect IP_ADDRESS_OF_PHONE:5555. You can find the IP_ADDRESS_OF_PHONE aprt, by going into your phone's wifi settings, clicking on the wifi you are connected to click on Advanced and then you see an IP address field. That's it

https://gist.github.com/steveclarke/d988d89e8cdf51a8a5766d69ecb07e7b#gistcomment-3541475

To achieve this, follow this gist

https://gist.github.com/jramiresbrito/846b9bebc560668eb2e7a97fb1cfc1ef

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