Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save trickpattyFH20/1afb3f1f9c3b00c0968ecdb3f9422565 to your computer and use it in GitHub Desktop.

Select an option

Save trickpattyFH20/1afb3f1f9c3b00c0968ecdb3f9422565 to your computer and use it in GitHub Desktop.
Ionic Android Development on WSL2 (Windows Subsystem for Linux)

Ionic Android Development on WSL2

Installing the required software

Execute the following commands to install Node, npm, git, Java, Ionic CLI:

cd ~
sudo apt update
sudo apt upgrade

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash
nvm install --lts
nvm use --lts

npm install -g @ionic/cli

sudo apt install git
git config --global user.email "you@yourmail.com"
git config --global user.name "Your Name"
git config --global core.autocrlf input

sudo apt-get update
sudo apt install openjdk-11-jdk

Downloading Android Studio

mkdir -p $HOME/Downloads && cd "$_"
wget https://r2---sn-npoe7nss.gvt1.com/edgedl/android/studio/ide-zips/2021.3.1.16/android-studio-2021.3.1.16-linux.tar.gz
mkdir -p $HOME/Applications && cd "$_"
tar xfv $(ls -1t $HOME/Downloads/android-studio-* | head -n1)

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

Install Android SDK and Tools using Android Studio

$HOME/Applications/android-studio/bin/studio.sh

Adding the Android SDK to your PATH

Add the following to your .profile (or .zshrc if you use zsh):

# Add Android SKD to PATH
ANDROID_SDK_ROOT=$HOME/Android/Sdk
export CAPACITOR_ANDROID_STUDIO_PATH=$HOME/Applications/android-studio
PATH="$HOME/Applications/android-studio/bin:$ANDROID_SDK_ROOT/platform-tools:$ANDROID_SDK_ROOT/emulator:$PATH"
export PATH

If ionic cap open android could not work, use studio.sh android & instead

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