Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save webdevsuperfast/4f33d651cc7d82c34584d3a1deab2c24 to your computer and use it in GitHub Desktop.
Save webdevsuperfast/4f33d651cc7d82c34584d3a1deab2c24 to your computer and use it in GitHub Desktop.
Ionic Android Development on WSL (Windows Subsystem for Linux)

Ionic Android Development on WSL

Installing the required software

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

cd ~
sudo apt update
sudo apt upgrade

curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs
sudo npm i -g ionic cordova @nestjs/cli @angular/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 add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer
sudo apt install oracle-java8-set-default

NOTE: Node can be installed via NVM (node version manager) on ZSH as described here: http://www.boekhoff.info/how-to-install-nodejs-and-npm-using-nvm-and-zsh-nvm/

Downloading the Android SDK Tools

To download the Android SDK tools in your home folder execute the following commands:

cd ~
sudo mkdir android-sdk
cd android-sdk
wget https://dl.google.com/android/repository/sdk-tools-linux-4333796.zip
unzip sdk-tools-linux-4333796.zip

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

Adding the Android SDK to your PATH

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

# Add Android SKD to PATH
export ANDROID_HOME=$HOME/android-sdk
PATH="$ANDROID_HOME/tools:$ANDROID_HOME/tools/bin:$ANDROID_HOME/platform-tools:$PATH"
export PATH

Installing the required Android SDK components

Execute the following commands to install some basic Android SDK components.

Note that you can install any component listed with sdkmanager --list by running sdkmanager "packagename". Always run sdkmanager --licenses to accept all the licenses after installing something.

sdkmanager --update
sdkmanager --list
sdkmanager "build-tools;26.0.2" "platform-tools" "platforms;android-26" "tools"
sdkmanager --licenses

Install Gradle

Install gradle with the following command:

sudo apt install gradle

ADB Alias

We can default to Windows's adb.exe (which can read USB) instead of the Linux one.

Create a ~/.aliases file with the following content:

alias adb='adb.exe'

ZSH

If you use ZSH, add the following to your .zshrc

source $HOME/.aliases

Bash

If you use bash, add the following to your .bashrc

if [ -f ~/.aliases ]; then
    . ~/.aliases
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment