How to Build an Android Development Environment Without Android Studio

Hire Remote Developers
By
|
Linkedin

Table of Contents

If you're looking for an alternative to Android Studio, this guide will show you how to create an Android development environment using only command-line tools.
Published on
September 20, 2022
Updated on
April 11, 2024

When starting mobile development for Android devices it’s common for us, developers, to choose Android Studio - Google's official development tool for the platform. Mainly, because it  offers a centralized environment for managing SDK versions, emulators, and other settings associated with the process of setting up your development environment.

When the app developed is native - be it in Kotlin or Java - opting for Android Studio does generate a differential when it comes to the speed of configuration for your development environment. However, when working with hybrid development frameworks - for example: React Native, Flutter, Ionic etc - the ease generated by this option becomes questionable, especially when we consider the computational cost associated with installing Android Studio.

At the time of this writing, for Android Studio Bumblebee version 2021.1.1 Patch 3 for MacOSX, we have the following hardware requirements:

  • x86_64 CPU architecture; 2nd generation Intel Core (or newer), or AMD CPU;
  • 8 GB RAM (or more);
  • 8 GB disk space (to store IDE + Android SDK + Android Emulator);
  • Minimum screen resolution of 1280 x 800.

Despite being a configuration that, for the present day, is easily served by the developers' hardware, when we talk about cross-platform development, it doesn't seem to make much sense to install Android Studio just to configure the development environment - it’s rare to find a cross-platform developer who uses Android Studio to work with Flutter, ReactNative or Ionic, for example.

Furthermore, opting for manual configuration is also justified based on resource optimization - since the tool remains installed (occupying about 8GB). But if manual configuration is used instead, it readily generates storage savings.

Installing Android SDK on MacOS

I will split this session into two parts - the first is optional, related to installing the homebrew package manager + Java SDK 1.8 - and the second, mandatory - related to installing Android SDK, setting up the Android Virtual Device, and using the Android Emulator.

Part 1 - Installing Homebrew + Java SDK 1.8 Package Manager

Before starting the installation process for Android SDK, we cannot forget that it is critical to have Java installed first. This is not the main topic of this article - if Homebrew and/or Java are already installed, this part can be (partially or completely) skipped as needed.

Homebrew Installation

Start the terminal of your choice and run:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

After that, Homebrew is installed. The next step is to install Java SDK 1.8.

Installing Java SDK 1.8

I usually set up my hybrid development environment using Java 1.8; I remember in the recent past having some problems running the emulator when, for example, I tried to use Java 1.9. So, just in case - and for the sake of knowledge - I will make use of this version. As you’ll see,  I will use OpenJDK in the process described here. To do so, in your terminal, run:

brew tap AdoptOpenJDK/openjdk

And then:

brew install --cask homebrew/cask-versions/adoptopenjdk8

A message about the discontinuation of the adoptopenjdk8 package will be displayed; so, at the end of the installation, run:

brew install --cask temurin8

to continue with a community-supported version.

Fun Fact: temurin8 is part of the migration from AdoptOpenJDK to Adoptium. More information can be found here

Moving on: when the installation process is complete, to check that Java is correctly installed, just run:

java -version

The output of the Java Runtime Environment installation should be:

openjdk version "1.8.0_322"

OpenJDK Runtime Environment (Temurin)(build 1.8.0_322-b06)

and

javac -version

The output of the Java Compiler should be:

javac 1.8.0_322

Part 2 - Installing Android SDK Manager

To install the Android SDK manager, you need to download the most current version of the tool (found at Android Developers) via the command:

curl https://dl.google.com/android/repository/commandlinetools-mac-8092744_latest.zip 

--output ~/Downloads/commandlinetools-mac-8092744_latest.zip

In addition to command-line-tools, you’ll need to download platform-tools:

curl https://dl.google.com/android/repository/platform-tools_r33.0.1-darwin.zip --output 

~/Downloads/platform-tools_r33.0.1-darwin.zip

After the download is complete, you’ll need to create the directory that will receive the tool extraction. There are three concatenated commands, the first one for creating the SDK directory, the second one containing the creation of the platforms subdirectory, and the third one containing the creation of the avd subdirectory.

Without creating the platforms subdirectory and the avd subdirectory, the Android Emulator will break at runtime, so we have to create them, even if they are empty "for now".

mkdir -p ~/Development/Android/sdk && mkdir -p ~/Development/Android/sdk/platforms && 

mkdir -p ~/Development/Android/sdk/avd

With the downloads complete and the directories created, it's time to extract the tools; first for command-line-tools:

unzip ~/Downloads/commandlinetools-mac-8092744_latest.zip -d ~/development/Android/sdk/cmdline-tools-tmp

and then the same for platform tools:

unzip ~/Downloads/platform-tools_r33.0.1-darwin.zip -d ~/development/Android/sdk/

For better directory organization, you’ll need to make an adjustment to the created structure in order to satisfy the execution of the tools via the command line. The adjustment must be made by running the following command:

mkdir -p ~/development/Android/sdk/cmdline-tools/latest && mv ~/development/Android/sdk/cmdline-tools-tmp/cmdline-tools/* ~/development/Android/sdk/cmdline-tools/latest && rm -rf ~/development/Android/sdk/cmdline-tools-tmp

Once that’s done, add the environment variables so that the operating system recognizes the commands executed via the terminal. Add the following to the file that manages your environment variables (~/.bash_profile, for example - in my case, since I use zsh, I use zshrc):

export ANDROID_SDK_ROOT="/Users/kckoerich/development/Android/sdk"

export ANDROID_CMD_LINE_TOOLS="$ANDROID_SDK_ROOT/cmdline-tools/latest"

export ANDROID_PLATFORM_TOOLS="$ANDROID_SDK_ROOT/platform-tools"

export ANDROID_AVD_HOME="$ANDROID_SDK_ROOT/avd"

after creating the variables, we must add them to the PATH:

export PATH="$PATH:$ANDROID_CMD_LINE_TOOLS/bin:$ANDROID_SDK_ROOT:$ANDROID_PLATFORM_TOOLS"

It’s important to remember that you must reload the configuration file using the command:

source ~/.zshrc or source ~/. bash_profile

All done, time to use the tools you installed.

How to Use Android SDK Manager

First, install the command line tools used by Android SDK (at this point, the directories created without content will be populated):

sdkmanager "platform-tools" "platforms;android-32" "build-tools;32.0.0"

With everything installed and configured, it's time to select a version of Android SDK and download it from the SDK manager to use for developing mobile apps.

To accept the terms of use for the SDK manager, we use the following command:

sdkmanager --licenses

To list the available versions of the SDK, use the following command:

sdkmanager -list

After choosing the desired version, it must be installed with the following command:

sdkmanager "system-images;android-32;google_apis_playstore;x86_64"

for more information about using SDK manager, use:

sdkmanager -help

Creating and Running an Android Virtual Device

After installing SDK, you’ll have to create an android device based on the chosen version, via avdmanager (Android Virtual Device manager); I usually create my emulators as follows:

avdmanager create avd --name android32 --abi google_apis_playstore/x86_64 --package 'system-images;android-32;google_apis_playstore;x86_64'

Explaining a little more about each part of the command:

create - for its creation

name - name of the emulator

package - the image used, based on the download executed by SDK manager

abi - (Application Binary Interface) the execution platform on which the emulator will be created

For more information about using avdmanager, please use:

avdmanager -help

Give execution permission to the emulator binary:

chmod +x ~/Development/Android/sdk/emulator/emulator

Create a symbolic link to the emulator:

ln -sf ~/Development/Android/sdk/emulator/emulator /usr/local/bin/emulator

After applying the settings above, run the emulator with the following command:

emulator @android32

The content after the @ is the name of the AVD you want to run. The skin parameter is optional, but it’s good  to use it so you can define the resolution on the emulator that will be executed.

Bonus - How to improve settings in the emulator you just created: 

Edit the config.ini file of the emulator you built (the file path is $ANDROID_AVD_HOME/android32.avd/config.ini), and replace the values of the variables shown with:

hw.keyboard = yes

hw.ramSize = 1024M

hw.lcd.height = 1280

hw.lcd.width = 720

hw.gpu.enabled = yes

With that, if I were to start developing a project with Flutter, my Android environment would be all set up, without relying  on Android Studio:

Pros vs Cons

I have outlined some pros and cons of this approach:

Pros

Cons

Download and Install only what is strictly necessary for development

Must have a background in the use of terminal tools

Independence from Android Studio use

Amount of manual configuration required 

Flexibility to customize the environment


Saving resources when setting up the development environment


Final Thoughts 

Of course, this process as a whole is not (at all) trivial. There are significant steps  (downloads, extractions, directory configurations, environment variable definitions, more downloads, more configurations, etc...) that could easily be replaced by downloading Android Studio + a series of clicks - the basic go, go and finish.

However, we must take into account that using Android Studio does not make sense in all scenarios - especially when it comes to hybrid development (using Flutter, ReactNative, Ionic etc). Android Studio only emerges when setting up some of the steps covered in this article, mainly because many developers use other IDEs and or toolsets during the coding process - for example VSCode, Sublime, Intellij etc.

Although not the most practical approach, applying the concepts as discussed in this article allows us to better understand each of the steps hidden behind the clicks within Android Studio. From downloading the SDK to creating the emulator, it is possible to view and control parameters in several different aspects – in order to optimize the use of the resources available in the development environment. Not that it wouldn’t be possible using Android Studio, but by configuring things manually, we become free of one more tool that in many scenarios is used purely for configuration.

Need to source and hire remote software developers?

Get matched with vetted candidates within 3 days.

Kaio Cesar Koerich

Location
Brazil

Software Developer

Kaio is a Software Developer with 13 years of experience helping with the development of clean, scalable, and maintainable backend solutions. He enjoys soccer, punk rock, coffee, and craft beer. He currently lives in Palhoça, Brazil.

Related blog posts

Software as a Service (SAAS) Business Challenges

SAAS Challenges

Rafael Timbó
READING TIME: 
Software Development
Web Application Development in 2023

Web Application Development

Celso Crivelaro
READING TIME: 
Software Development
Outsourcing Software Development to China: Everything You Should Know

Outsourcing Software Development to China: Everything You Should Know

Fred Monnier
READING TIME: 
Nearshoring

Subscribe to the Revelo Newsletter

Get the best insights on remote work, hiring, and engineering management in your inbox.

Subscribe and be the first to hear about our new products, exclusive content, and more.

Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.
Hire Developers