Last active
December 3, 2025 05:16
-
Star
(294)
You must be signed in to star a gist -
Fork
(83)
You must be signed in to fork a gist
-
-
Save jjvillavicencio/18feb09f0e93e017a861678bc638dcb0 to your computer and use it in GitHub Desktop.
Install Android SDK on Windows Bash (WSL)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
@qalqi
Thanks.
Here is my setup on WSL2 Arch. I need to change few more settings
React Native + Expo on WSL2 β Arch
Install Android SDK Command-line Tools
- Install
android-sdk-cmdline-tools-latest,jdkand optional dependencies (Arch Linux example):
yay -S android-sdk-cmdline-tools-latest android-sdk-platform-tools jdk-openjdkConfirm installation:
which sdkmanager
sdkmanager --versionConfigure Environment Variables in WSL2
Add the following to ~/.zshrc or ~/.bashrc:
# Android SDK
export ANDROID_HOME=/opt/android-sdk
export PATH=$PATH:$ANDROID_HOME/cmdline-tools/latest/bin
export PATH=$PATH:$ANDROID_HOME/platform-toolsApply changes:
source ~/.zshrc or source ~/.bashrcSet permissions for Android SDK directory:
sudo chown -R $USER:$USER /opt/android-sdkAccept SDK licenses and install packages
# Install platform-tools, SDK platforms, build-tools
sdkmanager --install "platform-tools" "platforms;android-36" "build-tools;36.0.0"
# Accept all licenses
yes | sdkmanager --licensesVerify installation:
adb version
ls $ANDROID_HOME/platformsConnect your phone via USB (initial setup)
Enable Developer Options β USB debugging on your phone.
Connect via USB. Set phone to Transferring files (MTP).
Setup Metro bundler for LAN access
Find Windows host IP on Wi-Fi:
ipconfigFind WSL2 IP:
ip addrForward port 8081 from Windows β WSL2:
netsh interface portproxy add v4tov4 listenaddress=192.168.xxx.xxx listenport=8081 connectaddress=172.18.xxx.xxx connectport=8081Allow port 8081 through Windows firewall:
- Open Windows Defender Firewall β Advanced Settings β Inbound Rules β New Rule β Port β TCP β 8081 β Allow β Private β Finish
Enable ADB over Wi-Fi
Find your phoneβs Wi-Fi IP:
Settings β Connections β Wi-Fi β gear icon β Advanced β IP address
Connect via Wi-Fi:
adb tcpip 5555
adb connect 192.168.xxx.xxx:5555
adb devicesPhone is now connected over Wi-Fi.
Create and start a React Native / Expo project
# Create new Expo app
npx create-expo-app@latest
# Start Metro bundler
npm startMetro should show:
Metro waiting on exp://192.168.xxx.xxx:8081
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is setup guide I used to install headless android studio in wsl2. courtesy: gemini pro
π οΈ Complete WSL2 Android SDK Setup Guide
This guide ensures you have a working
sdkmanager, platform tools (adb,fastboot), and the necessary Android platform 36 components installed and accessible from your WSL2 terminal.1. βοΈ Prerequisites and Setup
This assumes you have already downloaded and unzipped the Android Command-line Tools (e.g., to
$HOME/Android/cmdline-tools).1.1. Create the Directory Structure
Make sure your directory structure looks like this. If you haven't, run:
mkdir -p $HOME/Android/cmdline-tools1.2. Correctly Place the
cmdline-toolsMove the contents of the unzipped
cmdline-toolsfolder (which should contain abin,lib,NOTICE.txt, etc. directory/files) into a directory namedlatest:(The
sdkmanagerexecutable must be in$HOME/Android/cmdline-tools/latest/bin/)2. π Configure Environment Variables
You must add the necessary paths to your shell configuration file (
~/.bashrcor~/.zshrc) so the system can findsdkmanagerandadbfrom anywhere.Open your shell configuration file:
Add the following block to the end of the file:
2.1. Load the New Configuration
Apply the changes to your current terminal session:
3. π₯ Install SDK Packages
Now that the
sdkmanagercommand is available in your PATH, you can install the required components.Use the command you initially wanted to run, but without the
./prefix:"platform-tools": Installsadb,fastboot, etc."platforms;android-36": Installs the Android 36 SDK platform files."build-tools;36.0.0": Installs the necessary build tools (version 36.0.0 is used as a reference).4. β Accept Licenses
The SDK will not work until you accept the licenses. Use the
sdkmanagerfor this as well:yes | sdkmanager --licenses5. π¬ Verification and ADB Check
Check if everything is installed correctly:
Step 5.1: Verify
adbPathExpected Output:
/home/youruser/Android/platform-tools/adb(or similar)Step 5.2: Verify SDK Platform
ls $ANDROID_HOME/platformsExpected Output: You should see a folder like
android-36listed.Step 5.3: Check for Connected Devices (ADB)
To see devices, remember to use the correct command:
Expected Output (if no device is connected):
If you still get
Command 'android' not found, remember thatandroidis obsolete and has been replaced bysdkmanagerandavdmanager.This comprehensive list of steps should serve as a complete reference for your WSL2 Android SDK environment setup.