Skip to content

Instantly share code, notes, and snippets.

@jjvillavicencio
Last active October 11, 2024 19:54
Show Gist options
  • Save jjvillavicencio/18feb09f0e93e017a861678bc638dcb0 to your computer and use it in GitHub Desktop.
Save jjvillavicencio/18feb09f0e93e017a861678bc638dcb0 to your computer and use it in GitHub Desktop.
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
@agapiospanos
Copy link

agapiospanos commented Sep 25, 2022

You can easily replace <user> with $USER in the script. That will make things easier since we don't have to replace the any more... It will automatically get the current user ;)

@Dominique-Sakrisson
Copy link

This worked flawlessly thank you so much!

@brahmanandan
Copy link

Thank you, was useful!

@amorimcode
Copy link

java 11 version?

@nullset2
Copy link

nullset2 commented Jan 2, 2023

You can easily replace <user> with $USER in the script. That will make things easier since we don't have to replace the any more... It will automatically get the current user ;)

+1000000

Also, the android call on L16 can be changed to sdkmanager, since android as a command is deprecated

@yvmuogsedoz58122
Copy link

Thank you so much!!!

@Kousthubh02
Copy link

i am getting this error
image

@5p0ng3b0b
Copy link

5p0ng3b0b commented Mar 20, 2024

@Kousthubh02
/usr/bin/java is a symlink. I get the following:

ls -l $(which java)
lrwxrwxrwx 1 root root 22 Jan 28 23:07 /usr/bin/java -> /etc/alternatives/java
ls -l /etc/alternatives/java
lrwxrwxrwx 1 root root 43 Jan 28 23:07 /etc/alternatives/java -> /usr/lib/jvm/java-17-openjdk-amd64/bin/java
echo $JAVA_HOME
/usr/lib/jvm/java-17-openjdk-amd64

what does echo $JAVA_HOME give you?
You may need to add export JAVA_HOME=\path\to\java\install\location to your ~/.bashrc file and add export PATH=\path\to\java\install\location\bin;"$PATH" as well.

@Kulunkulu
Copy link

@5p0ng3b0b please can you confirm is the original gist above still works Aug 15th, 2024
I have been following different threads and gists referencing StackOverflow, in the StackOverflow, they are saying different things

for example you are suppose to move tools into cmdline-tools, only for an updated comment saying a new thing
i am so confused right now

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