Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Install Android SDK on Windows Bash (WSL)
cd /home/<user>/
sudo apt-get install unzip
wget https://dl.google.com/android/repository/sdk-tools-linux-4333796.zip
unzip sdk-tools-linux-4333796.zip -d Android
rm sdk-tools-linux-4333796.zip
sudo apt-get install -y lib32z1 openjdk-8-jdk
export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
export PATH=$PATH:$JAVA_HOME/bin
printf "\n\nexport JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64\nexport PATH=\$PATH:\$JAVA_HOME/bin" >> ~/.bashrc
cd Android/tools/bin
./sdkmanager "platform-tools" "platforms;android-26" "build-tools;26.0.3"
export ANDROID_HOME=/home/<user>/Android
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/platform-tools
printf "\n\nexport ANDROID_HOME=/home/<user>/Android\nexport PATH=\$PATH:\$ANDROID_HOME/tools\nexport PATH=\$PATH:\$ANDROID_HOME/platform-tools" >> ~/.bashrc
android update sdk --no-ui
sudo apt-get install gradle
gradle -v
adb start-server
@serhii-ilin

This comment has been minimized.

Copy link

serhii-ilin commented Jun 3, 2019

Are you able to run emulator from wsl ?

@vitorgja

This comment has been minimized.

Copy link

vitorgja commented Jun 29, 2019

Hi,
before first line you can include "sudo apt-get update". thank you

@bovesan

This comment has been minimized.

Copy link

bovesan commented Aug 5, 2019

Thank you!

To avoid the user variable:
1 cd
12 export ANDROID_HOME=~/Android
15 printf "\n\nexport ANDROID_HOME=~/Android\nexport PATH=\$PATH:\$ANDROID_HOME/tools\nexport PATH=\$PATH:\$ANDROID_HOME/platform-tools" >> ~/.bashrc

EDIT: Turns out the Ubuntu repo gradle is way updated.
Instead of line 17 sudo apt-get install gradle, I had to do

curl -s "https://get.sdkman.io" | bash
source "$HOME/.sdkman/bin/sdkman-init.sh"
sdk install gradle 5.5.1
@rwrz

This comment has been minimized.

Copy link

rwrz commented Aug 15, 2019

BIG TIP here, change the $PATH to the END, because if you have Android studio installed on your windows, you won't have issues with their PATHs...

export PATH=$ANDROID_HOME/tools:$PATH
export PATH=$ANDROID_HOME/tools/bin:$PATH
export PATH=$ANDROID_HOME/platform-tools:$PATH

I was having an EPERM error, that fixed with it.

@NobsterDev

This comment has been minimized.

Copy link

NobsterDev commented Aug 21, 2019

Thanks! Works perfect.

@UppaJung

This comment has been minimized.

Copy link

UppaJung commented Oct 9, 2019

Super helpful starting point!

I found it useful to substitute $HOME for /home/<user>

I had to add a /bin after /tools to one of the updates of the .bashrc

printf "\n\nexport ANDROID_HOME=$HOME/Android\nexport PATH=\$PATH:\$ANDROID_HOME/tools/bin\nexport PATH=\$PATH:\$ANDROID_HOME/platform-tools" >> ~/.bashrc

Since the android command is deprecated
android update sdk --no-ui should been replaced with sdkmanager --update

@Irikefe41

This comment has been minimized.

Copy link

Irikefe41 commented Oct 13, 2019

This guide is perfect ! Thanks, you just saved me hours of work

@alexksso

This comment has been minimized.

Copy link

alexksso commented Nov 23, 2019

missing --install on the package installer commandline, otherwise it won't prompt the license
./sdkmanager --install "platform-tools" "platforms;android-26" "build-tools;26.0.3"

Also, as you'll likely want to interact with devices, you'll need adb from the platform tools actually running on windows (not wsl)
get them here and launch it from powershell with adb start-server
make sure adb versions match on both wsl and windows.

@KROSF

This comment has been minimized.

Copy link

KROSF commented Nov 25, 2019

@alexksso can you share the steps to follow on windows 10

@alexksso

This comment has been minimized.

Copy link

alexksso commented Nov 25, 2019

@alexksso can you share the steps to follow on windows 10

I literally just followed the steps above. Do not launch adb from WSL though, launch it from a powershell - the wsl adb will find the deamon and connect to it seamlessly.

@KROSF

This comment has been minimized.

Copy link

KROSF commented Nov 27, 2019

@alexksso thanks.

@MarekJavurek

This comment has been minimized.

Copy link

MarekJavurek commented Nov 29, 2019

Thanks fir gist and comments guys!

@brombomb

This comment has been minimized.

Copy link

brombomb commented Dec 14, 2019

needed to add zip to the packages to install.... final script all together looks like this....

cd ~
sudo apt-get install unzip zip
wget https://dl.google.com/android/repository/sdk-tools-linux-4333796.zip
unzip sdk-tools-linux-4333796.zip -d Android
rm sdk-tools-linux-4333796.zip
sudo apt-get install -y lib32z1 openjdk-8-jdk
export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
export PATH=$PATH:$JAVA_HOME/bin
printf "\n\nexport JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64\nexport PATH=\$PATH:\$JAVA_HOME/bin" >> ~/.bashrc
cd Android/tools/bin
./sdkmanager --install "platform-tools" "platforms;android-26" "build-tools;26.0.3"
export ANDROID_HOME=~/Android
export PATH=$ANDROID_HOME/tools:$PATH
export PATH=$ANDROID_HOME/tools/bin:$PATH
export PATH=$ANDROID_HOME/platform-tools:$PATH
printf "\n\nexport ANDROID_HOME=~/Android\nexport PATH=\$PATH:\$ANDROID_HOME/tools\nexport PATH=\$PATH:\$ANDROID_HOME/platform-tools" >> ~/.bashrc
sdkmanager --update
curl -s "https://get.sdkman.io" | bash
source "$HOME/.sdkman/bin/sdkman-init.sh"
sdk install gradle 5.5.1
gradle -v

# run on windows in powershell
# adb start-server
@daniele-pecora

This comment has been minimized.

Copy link

daniele-pecora commented Dec 16, 2019

Thanks for gist and comments guys!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.