# WSL for Developers!: Installing the Android SDK

## Introduction

As any developer, you have probably started your career with a Windows machine, after some time you will begin to notice how Windows is horrible with development stuff (at least this is my opinion). For me, I wanted to switch to Linux so badly, Guess what? I did actually. Out of the blue Windows were a part of the past. and used Linux for almost 2 years! everything was perfect except for one thing that you probably know. Yes, that’s gaming. for me, Xbox wasn’t enough. I wanted a PC gaming experience. (note: dual boot is a pain in the ass)

In the meanwhile, Windows you know, was kind of getting better over time, with the best achievement of Microsoft arrived (that is WSL) I have switched back to Windows. Now I have both Windows gaming and Linux superpower!

## About this series

In this series (WSL for Developers!) I will document how I do I use WSL for my different development, for the sake of this series I will assume you have already installed WSL with the Ubuntu distro. You can search online for how to install WSL. Microsoft has an [official documentation for installing WSL](https://docs.microsoft.com/en-us/windows/wsl/install).

## Installing OpenJDK and Gradle

You probably know that Android development requires the JDK and Gradle to be installed. Let’s get this done.

```bash
sudo apt install openjdk-8-jdk-headless gradle
export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
```

You can install OpenJDK 11 if you want, for me I didn't face any issues with both.

## Installing Android Command Line Tools

First, we need to get the latest Android command-line tools. You can get it from [this link](https://developer.android.com/studio#downloads). (Make sure you get the one for Linux, not Windows)

```bash
cd ~ # Make sure you are at home!
curl https://dl.google.com/android/repository/commandlinetools-linux-8512546_latest.zip -o /tmp/cmd-tools.zip
mkdir -p android/cmdline-tools
unzip -q -d android/cmdline-tools /tmp/cmd-tools.zip
mv android/cmdline-tools/cmdline-tools android/cmdline-tools/latest
rm /tmp/cmd-tools.zip # delete the zip file (optional)

```

## Setting up environment variables

The Android SDK requires some environment variables to be set. Feel free to edit your `.bash_profile` or export them the way you like!

```bash
export ANDROID_HOME=$HOME/android
export ANDROID_SDK_ROOT=${ANDROID_HOME}
export PATH=${ANDROID_HOME}/cmdline-tools/latest/bin:${ANDROID_HOME}/platform-tools:${ANDROID_HOME}/tools:${ANDROID_HOME}/tools/bin:${PATH}

```

## Accepting SDK licenses

You got it right? we need to agree to some licenses. You probably should read them (if you haven’t already).

```bash
yes | sdkmanager --licenses

```

## Installing SDK components

Now the final part, let's install what we need, feel free to adjust the versions or components depending on your needs!

```bash
sdkmanager --update
sdkmanager "platforms;android-30" "build-tools;30.0.3"

```

You can get a list of all the components available and their versions by running:

```bash
sdkmanager --list
```

## Final thoughts

Up to this point, you can build your android apps from inside WSL, but isn’t this all about development? where is the emulator? or even attaching a device with USB? What about my IDE and coding experience?
Well to be honest those are topics for the up coming article of the series (WSL for Developers!). I like lightweight articles that’s my style of writing. Don’t worry there is more coming next!

## Thanks!

Thanks for reading and coming to the end. I wish that you have enjoyed it and of course found it useful.
I would like to thank you that you have given my first article/post a chance and I hope that I will get better over time.
