DEV Community

Cover image for Adding environment variables and java packages to use android studio and emulator.
Gautham Vijayan
Gautham Vijayan

Posted on • Updated on

Adding environment variables and java packages to use android studio and emulator.

Before you start developing android apps or iOS apps with react native or with java/kotlin with android studio, you have to install a bunch of java stuff and set environment variables to path variables correctly.

If you hesitate to do it, you will waste a lot of precious time as I did while scrolling through stack overflow and other forums for hours.

So lets learn how to setup your system for mobile app development.

Small bit of backstory [Feel free to skip]:

I bought a good laptop for college with education loan and I forgot to include all the environment variables and struggled a lot. Now finally, I have configured my machine to compile react native apps and even java/kotlin apps perfectly and run it on an emulator.

This tutorial will almost solve all your installation problems.

First steps:

Forget everything you did before and start fresh!

Install Java's jre and jdk by downloading them from the given links below.

I made a big mistake of not downloading and installing jdk and started to get all sorts of errors.

The links to jre and jdk are below.

Carefully select the version and your OS specific ones and download and install them.

Now go to environment variables in your system and do as below.

chrome-capture (24)

Type the exact variable as I am typing here.

In Environment variables set JAVA_HOME to the location of your jdk and not jre.

JAVA_HOME --> C:\Program Files\Java\jdk-12.0.1

chrome-capture (29)

Now download android studio from the link below.

Android-Studio Link

After installing the android SDK along with the android studio, we have to set its path to environment variables.

Do the same as you did with Java jdk here as well.

chrome-capture (26)

ANDROID_HOME --> C:\Users\YOUR_USERNAME\AppData\Local\Android\Sdk

After doing that, you need to add three other SDK paths to the path variable like below.

You have to add,

  • The path to emulator, C:\Users\YOUR_USERNAME\AppData\Local\Android\Sdk\emulator
  • The path to the bin, C:\Users\YOUR_USERNAME\AppData\Local\Android\Sdk\tools\bin
  • The path to the platform tools, C:\Users\YOUR_USERNAME\AppData\Local\Android\Sdk\platform-tools

chrome-capture (28)

After doing all the above steps carefully in the right place, you can now now build android apps without any issues.

Keep in mind to do all these steps again when you buy a new system, or you will really have a tough time figuring out what is the problem.

Now to access the emulators in the avd manager via the terminal, You can use the below code.

To list all the emulators,


emulator -list-avds

Enter fullscreen mode Exit fullscreen mode

To start an the emulator,


emulator -avd name

Enter fullscreen mode Exit fullscreen mode

To check the connected adb devices


adb devices.

Enter fullscreen mode Exit fullscreen mode

Now if we want to sign our developed app and publish it to the playstore, we need to download gradle.

Here is the link to the official gradle website:gradle

Now after manually downloading the latest gradle package, we need to set it to the environment variables, so do as below,

1 .Extract the downloaded winrar file to program files in C drive.

  1. After that we have to set two environmental variables. One is GRADLE_HOME = C:\Program Files\gradle-6.7.1

Another one is

Path variable > new > C:\Program Files\gradle-6.7.1\bin

chrome-capture (39)

chrome-capture (40)

After doing these steps, you can easily sign an apk with gradle and publish it to playstore.

Now to check whether the apk is signed or not we can use jarsigner

So now include the jdk/bin in the environment path variables.

The jdk bin will be located atC:\Program Files\Java\jdk-12.0.1\bin

After that go to your apk file location folder and use the following code,


jarsigner -verify -verbose -certs my_application.apk

Enter fullscreen mode Exit fullscreen mode

This will tell you whether the apk is signed or not.

If you get any errors hop on to this stackoverflow thread to solve it.

I wish people automated this stuff by setting all these environment variables at its appropriate place when installing the specific software.

Its too time confusing and frustrating to find out these were causing the problems and finding them in stack overflow and in forums.

As a beginner its a nightmare. But as I became more experienced it was not a big issue.

I have given you the list of all of them just use it whenever you need!

Thank you for reading!!

Check out my portfolio: Gautham's portfolio

Check out my blog: coding-magnified.tech

If you want to appreciate my or support me, you can buy me a coffee with the link below,


Buy Me a Coffee

My Other Articles:

Top comments (0)