How To Setup Android SDK Without Android Studio. by Nitish Sharma ProAndroidDev
How To Setup Android SDK Without Android Studio. by Nitish Sharma ProAndroidDev
Listen Share
The foundation of android mobile development using any library is the “Android
SDK”. Android SDK is the prerequisite for building android apps, be it via native
Kotlin, or other popular libraries like React Native and Flutter.
Now I’ve been building apps using React Native for about 4 years now, and didn’t
have any need for a full-fledged Android Studio IDE other than to install SDK(s) and
emulator(s). Also I’ll be honest, it’s a big IDE, till last month I was using a early 2015
macbook air with 128G of storage, so you can guess yourself how precious the space
was to me.
Also, I like using command line as much as I can, because for me, it’s easier than the
GUI (debatable, I know, but we all have our preferences).
So I looked for a way to install Android SDK and other stuff, without installing the
“Android Studio”, and I found it. Fortunately, Google has provided us with Android
Command-Line Tools. So in this article I would like to show you how you can set it
up.
Prerequisites
For this guide I assume you’ve already installed the Java JDK of your choice. I’d
suggest installing openjdk8, as it is prime choice for Android development, You can
install it via commands below.
For Mac -
For Linux -
You may download and install OpenJDK from AdoptOpenJDK or your system
packager.
Moving on, follow the Steps below to setup Android tools and install Android SDK.
Click on this link to visit the download page, then to the Command Line Tools Only
section, and Download the zip file according to you operating sytem (preferably
Linux OR Mac, If you are using windows, switch your OS).
Here is the section you need to visit and click on the tools next to your operating system
Now after you’ve downloaded the zip file, move it to your home location i.e. ~/ .
Now there’s another way to do this in one step, you can just copy the link to the zip
file, then open a terminal window and:
First we need to create a directory to store the android sdk and other stuff, so open a
terminal window and follow the steps:
~ $ mkdir android
~ $ cd android
Then we need to move and unzip the tools in android directory we just created:
~/android $ mv ~/commandlinetools-mac-6858069_latest.zip ./
~/android $ unzip commandlinetools-mac-6858069_latest.zip
~/android $ rm commandlinetools-mac-6858069_latest.zip
You can change the file name according to yours. At the time this article was written
this was the latest zip avaialable (for mac).
Now, here’s the tricky part which even confused me the first time I setup android
tools.
The above created android directory will act as our $ANDROID_HOME so other
libraries can access is from the environment variables we’re going to add ahead.
After unzipping the content, you will get a directory named cmdline-tools, now
follow the next steps carefully.
$ cd cmdline-tools
$ mkdir tools
$ mv -i * tools
Last command will probably give you a warning, but you don’t need the worry about
that.
After running the commands above the new directory structure should look like
something like this:
android
└── cmdline-tools
└── tools
├── NOTICE.txt
├── bin
├── lib
└── source.properties
The file in which you have to append the PATH of the tools is in your home directory
~. for a bash terminal it’s .bash_profile where as for the newer zsh terminals it’s
.zshrc.
Now before we can add tools to path we have to add $ANDROID_HOME to the path,
to do that just open the .zshrc or .bash_profile in you preffered terminal file editor
(nano or vim) and add the following code at the end of the file:
export ANDROID_HOME=$HOME/android
export PATH=$ANDROID_HOME/cmdline-tools/tools/bin/:$PATH
export PATH=$ANDROID_HOME/emulator/:$PATH
export PATH=$ANDROID_HOME/platform-tools/:$PATH
After adding the code, save the file, close the terminal window and open a new
terminal window (I prefer this way as it makes reloading easier, without extra
commands).
After you’ve opened a new terminal window just type the following command and
hit return/enter.
$ sdkmanager
If you see the following progressbar, your tools have setup successfully:
If not you can go through the guide and check if you’ve followed the steps carefully.
If the probrem persists, feel free to drop in a comment.
Use the following command to list all the available sdks, platform-tools, build tools,
emulator, ndks and what-not.
$ sdkmanager --list
To install the package you want, just copy the package name and install:
This will install all the basic necessary tools you’ll require to start up your android
development.
Conclusion
If you’ve reached here, Congratulations, again. You’ve successfully setup your
Android Development Environment, without Android Studio. You can use the
library you’d like to work with i.e React Native or Flutter etc.
Although, the tools above should suffice for building your basic debug app, but, if
any other tools are to be installed, the libraries handle the installation automatically
for the most part, if not you can follow Step 4.
CHEERS!
Follow
Web and Mobile Developer (React.Js, React Native, Expo, Electron, Firebase, Amplify). India 🇮🇳
https://www.linkedin.com/in/nitishxyz
Nek.12 in ProAndroidDev
865 5
368 4
511 9
215 2
Julien sez'n
Satish Thakur
42
Lists
Staff Picks
535 stories · 528 saves
Jekayin-Oluwa Olabemiwo
51
Top Tools for Android Static Code Analysis: Streamline Your Development
Process
As the demand for feature-rich and secure Android applications continues to grow, developers
are constantly seeking ways to enhance their…
Gavin Fong
23