0

I am trying to do some Android Automation using Python/Appium on GitLab. I have found the way to create and launch the Android Emulator using the command line options. But when the emulator opens, it requires the Google Account Setup in order to use Play Store/Gmail etc.

Creating a script through Appium is possible but would be little bit tedious work. Is there any simpler way using some command line configuration during the initial setup to automatically setup the Google Account

avdmanager create avd --force --name "MyEmulator" --package "system-images;android-31;google_apis_playstore;x86_64" --device "pixel"

Hemendra
  • 81
  • 8

1 Answers1

0

I've found you just need to pipe echo "no" into avdmanager create then start the emulator.

Something like this:

echo "y" | sdkmanager "system-images;android-31;google_apis_playstore;x86_64"
echo "no" | avdmanager create avd -n MyEmulator -k "system-images;android-31;google_apis_playstore;x86_64"
emulator64-arm -avd MyEmulator -noaudio -no-window -accel on
sleep 300 # wait for avd to start
# or detect when booting is finished

See also: How to create Android Virtual Device with command line and avdmanager?

You'll also need to wait for the avd to start. You can either sleep for a reasonably long period of time or try something more sophisticated like polling adb -e shell getprop init.svc.bootanim to see if the output says "stopped" -- example reference.

sytech
  • 29,298
  • 3
  • 45
  • 86