This setup is assuming that GUI Linux apps can run in your WSL2.
Execute the following commands to install Node, npm, git, Java, Ionic CLI:
cd ~
sudo apt update
sudo apt upgrade
# Replace bash if you are using other shells e.g. zsh
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 "[email protected]"
git config --global user.name "Your Name"
git config --global core.autocrlf input
sudo apt-get update
sudo apt install openjdk-11-jdk
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
Run the Android Studio and install the necessary tools with the GUI wizard
$HOME/Applications/android-studio/bin/studio.sh
Add the following to your .profile
(or .zshrc
if you use zsh):
# Add Android SDK to PATH
export 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
sudo apt install qemu-kvm
sudo adduser $USER kvm
Create a new file /etc/wsl.conf
with the following content:
[boot]
command = /bin/bash -c 'chown root:kvm /dev/kvm && chmod 660 /dev/kvm'
Reboot your machine.
- Run
ionic cap add android
for new project - Run
ionic cap sync android
for existing project - Run
ionic cap open android
- If
ionic cap open android
could not work, usestudio.sh android &
instead