Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to cold boot emulator using commend line(CMD)

I am trying to open emulator without opening android studio every time while developing react-native. Emulator can be opened using this lines of code.

cd C:\Users\<your_user_name>\AppData\Local\Android\Sdk\emulator
emulator -list-avds
emulator @<your_adb_name>

But now I want to cold-boot emulator some times to resolve emulator not responding issue using cmd. Any idea to solve that?

Thanks in advance.

like image 490
Arnab Kundu Avatar asked Feb 25 '21 04:02

Arnab Kundu


People also ask

How do I run an emulator from command prompt?

Use the emulator command to start the emulator, as an alternative to running your project or starting it through the AVD Manager. Here's the basic command-line syntax for starting a virtual device from a terminal prompt: emulator -avd avd_name [ {- option [ value ]} … ]

How do I terminate an emulator?

To stop a running emulator, click Menu and select Stop.


2 Answers

I am able to solve my this problem using -no-snapshot-load with emulator @<your_adb_name>

cd C:\Users\<your_user_name>\AppData\Local\Android\Sdk\emulator
emulator -list-avds
emulator @<your_adb_name> -no-snapshot-load
like image 163
Arnab Kundu Avatar answered Oct 12 '22 00:10

Arnab Kundu


On linux, if you add this to your .bashrc, when you call avd-coldboot (or whatever you decide to name it) you will get a list of AVDs to select from for cold-booting.

This should work regardless of how many AVDs you have set up

function avd-coldboot {
echo 'Choose Android AVD to cold-boot:'

select avd in $(emulator -list-avds);
do
  if [ -n "$avd" ]
  then
    echo "Cold-booting AVD '$avd'"
    emulator @$avd -no-snapshot-load
    break
  else
    echo "Unknown option: '$REPLY'"
  fi
done
}

Example terminal I/O

~/jnk$ avd-coldboot
1) Pixel_3a_API_30
2) Pixel_4_API_30
#? 1 
emulator: Android emulator version 30.7.5.0 (build_id 7491168) (CL:N/A)
like image 20
FriskyGrub Avatar answered Oct 12 '22 02:10

FriskyGrub