Usually, we install Android Studio to run our code in its Android Emulator. This emulator is usually called AVD (Android Virtual Device) Emulator, which is a very handy tool especially if you don't want to setup your personal device for the testing usecase. But, sometimes you don’t need Android Studio but still need the AVD Emulator, so it's just overkill to install heavy Android Studio to just run Android Emulator.
So we'll see how we can install and run AVD Emulator without installing Android Studio. Here’s the step to step guide to install AVD Emulator to your Mac without installing Android Studio. Same can be followed for linux based devices.
Install Java (If already not)
Java is used to build and run the emulator and related tools. Java must be installed in your system. You can download Java by following below steps:
- Download appropriate Java package or installer from
- If you use the installer(recommended), that will set appropriate paths as well.
Get Tools package
toolspackage is part of Android SDK, a group of packages that are needed for Android development.toolspackage is used for managing other packages to create AVD's. Here's the step for getting the tools package:
- Go to Official
- Download the package according to your OS by clicking on it.
- Extract the package to the folder you want. I use below for my Macbook:
- Single User:
/Users/shivamsharma/Library/Android/sdk
- Globally:
/Library/Android/sdk
- Single User:
- Move content of
cmdline-toolsto a folder namedlatestinsidecmdline-tools. e.g. Final path for bin becomes:/Users/shivamsharma/Library/Android/sdk/cmdline-tools/latest/bin
Add Environment variables
We need to add environment variable to our bash/zsh profile for Android and Java Executables. By doing this we'll be able to run the command line tools or binary files from evrywhere in the machine.
To do the same
- Add below content in your bash file e.g.
~/.zshrc:
CODE######## Android #########
export ANDROID_SDK_ROOT="/Users/shivamsharma/Library/Android/sdk"
export ANDROID_HOME="/Users/shivamsharma/Library/Android/sdk" #(Deprecated, but some programs still using it to locate SDK)
export PATH="$ANDROID_HOME/cmdline-tools/latest/bin/:$PATH"
export PATH="$ANDROID_HOME/emulator/:$PATH"
export PATH="$ANDROID_HOME/platform-tools/:$PATH"
- Source the bash file by running
source ~/.zshrc. As we have added path ofcmdline-tools/latest/bin/inPATHso we can call CLI commands available in that folder from anywhere.
Download essential packages
Now, we will download
platform-toolsandemulatorpackages.
platform-toolshas some tools to communicate with Android devices when you plug them into your computer.emulatoris the Android emulator.
We will usesdkmanagerorsdkmanager.batwhich are placed atcmdline-tools/binto install them.
You can check if
sdkmanageris working by runningsdkmanager --list. This will give the list of packages available to install withsdkmanager.
Use
control + cin the terminal to close the emulator. Or switch off the device emulator using android controls.
Steps Summary
- Install Java:
- e.g.
/Users/shivamsharma/Library/Android/sdkfor single user, for global user at/Library/Android/sdk
- e.g.
- Move content of
cmdline-toolsto a folder namedlatestinsidecmdline-tools. e.g. Final path becomes:/Users/shivamsharma/Library/Android/sdk/cmdline-tools/latest/bin
- Add below content in
~/.zshrc
CODE######## Android #########
export ANDROID_SDK_ROOT="/Users/shivamsharma/Library/Android/sdk"
export ANDROID_HOME="/Users/shivamsharma/Library/Android/sdk"
export PATH="$ANDROID_HOME/cmdline-tools/latest/bin/:$PATH"
export PATH="$ANDROID_HOME/emulator/:$PATH"
export PATH="$ANDROID_HOME/platform-tools/:$PATH"
- Reload source file:
source ~/.zshrc. As we have added path ofcmdline-tools/latest/bin/inPATHso we can call CLI commands available in that folder from anywhere. - Check if you can run
sdkmanager --list
- Run
sdkmanager platform-tools emulatorto install platform-tools and emulator. Read and accept licences. - Run
sdkmanager "system-images;android-34;google_apis_playstore;arm64-v8a" "platforms;android-34"to install android image you are interested in e.g. usingandroid-34here which is SDK for Android 14. Read and accept licences. - Create device with command
avdmanager create avd --name '${DeviceName}' --package "system-images;android-34;google_apis_playstore;arm64-v8a" -d pixel
- Run emulator by
emulator -avd ${DeviceName} -no-snapshot-load.-no-snapshot-loadis there to load the device from fresh instead of from a snapshot.
↗ Original-Artikel auf dev.to lesenVollständiger Original-BerichtAusführliche Details, Code-Beispiele & Hersteller-Stellungnahme auf dev.to.
SOCIAL SHARE CARD GENERATOR