Create android emulator with command line

Manit Cholpinyo
1 min readMar 15, 2022

--

Basic create Android emulator by using command line

1. Install JAVA 8 or later official release

2. Install Android SDK https://developer.android.com/studio

3. Setup ANDROID_SDK system environment variable:

export ANDROID_SDK=$HOME/Library/Android/sdk
export PATH=$ANDROID_SDK/emulator:$ANDROID_SDK/tools:${ANDROID_SDK}/tools/bin:${ANDROID_SDK}/platform-tools:$PATH

4. List all android system images

sdkmanager --list | grep system-images

5. Download image Android-API version

sdkmanager --install "system-images;android-31;google_apis_playstore;x86_64"

6. Create an emulator

echo "no" | avdmanager --verbose create avd --force --name "my_android_31" --package "system-images;android-31;google_apis_playstore;x86_64" --tag "google_apis_playstore" --abi "x86_64"

7. Config your emulator (Optional)

code ~/.android/avd/my_android_31.avd/config.ini
PlayStore.enabled=true
abi.type=x86_64
avd.ini.displayname=Pixel 3 API 30
avd.ini.encoding=UTF-8
disk.dataPartition.size = 6442450944
fastboot.chosenSnapshotFile=
fastboot.forceChosenSnapshotBoot=no
fastboot.forceColdBoot=no
fastboot.forceFastBoot=yes
hw.accelerometer=yes
hw.arc=false
hw.audioInput=yes
hw.battery=yes
hw.camera.back=webcam0
hw.camera.front=emulated
hw.cpu.arch=x86_64
hw.cpu.ncore=4
hw.dPad=no
hw.device.hash2=MD5:8a60718609e0741c7c0cc225f49c5590
hw.device.manufacturer=Google
hw.device.name=pixel_3
hw.gps=yes
hw.gpu.enabled=yes
hw.gpu.mode=auto
hw.initialOrientation=Portrait
hw.keyboard=yes
hw.lcd.density=440
hw.lcd.height=2160
hw.lcd.width=1080
hw.mainKeys=no
hw.ramSize=1536
hw.sdCard=yes
hw.sensors.orientation=yes
hw.sensors.proximity=yes
hw.trackBall=no
image.sysdir.1=system-images/android-31/google_apis_playstore/x86_64/
runtime.network.latency=none
runtime.network.speed=full
sdcard.path=/Users/localadm/.android/avd/Pixel_3_API_30.avd/sdcard.img
sdcard.size=512 MB
showDeviceFrame=no
skin.dynamic=yes
skin.name=1080x2160
skin.path=_no_skin
skin.path.backup=_no_skin
tag.display=Google Play
tag.id=google_apis_playstore
vm.heapSize=256

You can config option follow this document

See: Google Documentation on Start the emulator from the command line for more info

8. Open emulator

emulator @my_android_31

Other commands

  • List available emulator
emulator -list-avds
  • Cool start emulator
emulator @my_android_31 -no-snapshot-load

Thanks :) For more information

https://gist.github.com/mrk-han/66ac1a724456cadf1c93f4218c6060ae

https://guides.codepath.com/android/Installing-Android-SDK-Tools#installing-the-android-sdk-automated-way

https://www.droidviews.com/install-apk-files-using-adb-commands/

--

--