DEV Community

Enrique Matta-Rodriguez
Enrique Matta-Rodriguez

Posted on

Android SDK without Studio

Android SDK w/o Studio

Android Studio is bloat for developers who work on React Native or other third party tooling that isn't native or java Android development. It's a full blown IDE you might never open up, especially in a CI-CD pipeline. To get around this need, follow along and install Android SDK w/o the IDE.

**

Java

You will need to download and install java since most of the tooling revolves around it. I would highly suggest not using anything above Java 8. If you have a need for a newer version of the JVM you can follow a multi environment setup.

Single JVM Environment

The simplest way to get up and running with Java is to install the AdoptOpenJDK version 8 cask from brew:

brew tap adoptopenjdk/openjdk
brew cask install adoptopenjdk8
Enter fullscreen mode Exit fullscreen mode

Another route (outside of brew) is with sdkman. This is a general JVM tooling that can allow for multiple JVMs to be installed. For our purpsoe, all you will need to do (after installing sdman is to run sdk install java 8.0.272.hs-adpt and then run sdk home java 8.0.272.hs-adpt to get the JAVA_HOME env var (export JAVA_HOME="$(sdk home java 8.0.272.hs-adpt)").

Multi JVM Environment

If there is a need to have multiple versions of the JVM I highly suggest you install via sdkman and install jenv. Unlike other version management toolings, like pyenv, nvm, or nodenv, you cannot install a JVM directly from jenv. Instead, you install them via sdkman and add all your JVMs in via jenv add $(sdk home java [version]). Once in the list, go to the root of the app and ensure that your local is pointed to Java 8 (jenv local 1.8). This is very important for the next portion.

Android SDK

First, you will need to visit the Android Studio download site and scroll until you see Command line tools only near the bottom and download the zip. I have a cURL below but it might be outdated by the time you read this, so go and download it there first instead.

When downloaded unzip that badboy anywhere you want and make sure you point ANDROID_SDK_ROOT to it.

Here is a convinient script for you, but keep in mind it might be outdated:

curl https://dl.google.com/android/repository/commandlinetools-mac-6858069_latest.zip -o $HOME/android-sdk.zip
unzip $HOME/android-sdk.zip -d $HOME/.tmp-android
mkdir $HOME/.android-sdk && mkdir $HOME/.android-sdk/cmdline-tools
mv $HOME/.tmp-android/cmdline-tools $HOME/.android-sdk/cmdline-tools/latest
rm -rf $HOME/android-sdk.zip $HOME/.tmp-android/
export ANDROID_SDK_ROOT="$HOME/.android-sdk"
yes | $ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager --update
yes | $ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager \
    "system-images;android-29;default;x86_64" \
    "platforms;android-29" \
    "build-tools;29.0.3" \
    "extras;google;m2repository" \
    "extras;android;m2repository"
yes | $ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager --licenses
Enter fullscreen mode Exit fullscreen mode

If you are ever curious about what packages you have available to install you can run sdkmanager --list to view them. After installing the SDK you will need to add the following to either your .bash_profile or .zshrc:

export ANDROID_SDK_ROOT="$HOME/.android-sdk"
export PATH="$PATH:$ANDROID_SDK_ROOT/cmdline-tools/latest/bin"
export PATH="$PATH:$ANDROID_SDK_ROOT/platform-tools"
export PATH="$PATH:$ANDROID_SDK_ROOT/tools"
Enter fullscreen mode Exit fullscreen mode

Once installed you can create simulators via the CLI with avdmanager create avd --name test-avd --package "system-images;android-29;default;x86_64".

And there you have it, a version of the SDK without having to download Android Studio.

Top comments (0)