First you’ll need to install JDK 8. Windows and linux users can directly visit the link and download it after accepting the license. For Mac users, I recommend installing via Homebrew :
brew tap caskroom/versionsbrew cask install java8
Windows and Linux users should make sure that they have set-up path to their Java installation.
Step 1: Install Android SDK Command Line Tools
Once we have installed and set-up Java in our system, we will need to install Android SDK so that we can get necessary tools in our systems including the android virtual device manager and emulator itself!
Then you simply need to run the below command and try installing android-sdk again :
touch ~/.android/repositories.cfg
After installing, make sure you have added android-sdk to your system path.
For Mac and Linux users, you need to add the following line to your .bashrc or .zshrc :
export ANDROID_HOME=/path/to/android-sdk
important
Note for the next two steps:
Incase your system complains about not being able to find the command while trying to issue the next set of commands involving sdkmanager , avdmanager or emulator — you can navigate to the directory where it is present inside the android-sdk folder and run them as ./sdkmanager , ./avdmanager and ./emulator respectively.
For those of you who are feeling lazy to find it yourself :
sdkmanager and avdmanager will be located inside android-sdk/tools/bin whereas emulator can be found inside android-sdk/tools.
Now that we know this, let’s continue towards a better development experience!
Step 2: Install Required Platform Tools, Build Tools, and Emulator
Now we can go ahead and set-up platform and build tools to help us in creating and running our virtual device in android emulator. We will use the sdkmanager that we just downloaded to our system as a part of android-sdk.
To do this, open your terminal and run the following command :
Once we have downloaded the above packages, run the following command to list all the tools available :
sdkmanager --list
This will fetch the complete list of the available packages on remote that you can download to your system. You can download packages from the list by running :
sdkmanager "sdk-path-for-package"
Note: sdk-path is the string in the leftmost column of the generated list. And it must be wrapped in quotes while running the above command. For example, let’s say we want to create a virtual device which requires Google APIs Intel x86 Atom System Image package, we can install the package by running:
You can download the packages that you need from the list and if you look closely, you’ll find android emulator package there too! But don’t worry I won’t make you go through the long list in your terminal, here’s the command you need to run in order to download the android emulator package :
sdkmanager "emulator"
That’s it! We’ve downloaded the android emulator and we’re ready to set-up our Android virtual device!
Step 3: Create a New Android Virtual Device (AVD)
Let’s create an android virtual device with the help of Google APIs Intel x86 Atom System Image we downloaded through the previous command, which was :
This will create a virtual device named myTestDevice using the Intel x86 Atom system image we downloaded.
To check if your device was created, you can run :
emulator -list-avds
This will list all the virtual devices present in your system.
Step 4: Run the Android Emulator
If you followed all the instructions properly, you can see your device listed as well and you must be able to start your virtual device by running :
emulator -avd myTestDevice
And now your android emulator will start with the device you just created! But this time in a better way just like you always deserved — without wasting your precious storage space! 🎉
Did you like this article? Or did I miss something? Is there something that you have that can be added to this article — that can make it even better?
Please leave a comment below or you can also contact me through my social media profiles.
Thank you for reading! 😄
Happy Hacking! Cheers!
Continue Reading
Discover more insights and stories that you might be interested in.