Install Android SDK Without Android Studio10 March, 2021written by Bill

Android Studio is one of the best development tool to create Android application. But we know that this tool is too heavy for some machines, like mine. In order to develop an Android application, we need to use their SDK which is available to be download separately. So let's get started.

1. Prerequisite Tools

First, we need to download the latest SDK from Android official website and navigate to the Command line tools only then download the file based on your OS, in this case I'm using Linux. Another tool we need to use is Gradle (optional), please download the latest Gradle file.

2. Manual Setup

Since we're not using Android studio bundle system, we need to setup the tools manually. I'm going to use /home/username/bin/ for the installation directory. The installation directory would be like /home/username/bin/android/sdk/cmdline-tools/latest and /home/username/bin/android/gradle. Extract the SDK or cmdlinetool and Gradle file inside our installation directory. The structure is supposed to be the following:

  /home/username/bin/android/sdk/cmdline-tools/latest/
    |_bin/
    |_lib/
    |_NOTICE.txt
    |_source.properties

  /home/username/bin/android/gradle/gradle-x.x.x/
    |_bin/
    |_docs/
    |_init.d/
    |_lib/
    |_src/
    |_LICENSE
    |_NOTICE
    |_README

Before set our environment variable, try to run the cmdline-tools/bin/sdkmanager script from terminal command by running ./sdkmanager --list you'll get a list of available packages.

3. Install Packages

We need to install such packages like system-images;android-x;google_api;x86_64, platform;android-x, platform-tools, build-tools;x.x.x, where x means the version.

  ./sdkmanager "platforms;android-30" "system-images;android-30;google_apis;x86_64" "platform-tools"
  ./sdkmanager --licenses

In order to connect our real device to the application, we need to install an additional packages, please install the following packages: sudo pacman -S libmtp android-tools android-udev (the package name for other Linux Distro might be different).

Now we create new entry in Path environment variable.

  vi ~/.bashrc
    # Android SDK files
    export ANDROID_HOME="$HOME/bin/android/sdk"
    export PATH=$PATH:$ANDROID_HOME/cmdline-tools/latest:$ANDROID_HOME/cmdline-tools/latest/bin:$ANDROID_HOME/platform-tools
    # Gradle
    export PATH=$PATH:$HOME/bin/android/gradle/gradle-x.x/bin

4. Testing and Run

We are ready to create new virtual device.

  avdmanager create avd -n image_v29 -k "system-images;android-29;google_apis;x86_64"
  avdmanager list avd

Go to emulator directory and try to launch the virtual device by running the following command:

  emulator -avd image_v29

But if you want to develop your application from your device, you need to enable developer option and enable USB debugging, since we're already install the packages, we can easily plugged-in the phone to our machine and then allow the permission and we're done. Please refer to the internet, there are so many tutorial about it.

It is a little tricky but now we are done. We don't need to use Android studio to create and develop our application, with those tools, we can still run the application through AVD or even our Android phone.

Linux

Reading Time2 min



© Repodev - Muh Ibnu Habil Hanafi