I'm writing an automated emulator script that will create and launch an Android emulator so I can run my UI tests from any machine and guarantee that it'll run on a device.
My current script creates an android-27;google_apis;x86
device which works fine, but lacks google services so the maps in my app do not show.
I tried creating an emulator using google_apis_playstore
, but when the device boots, it prompts with an ADB debugging prompt. Normally tapping this would be fine, but Im expecting to be able to run this on a headless server and wont always be able to.
Is there anyway to create the emulator that will have google apis + maps without having to accept an ADB dialog?
Here's my current shell script
#!/bin/sh
# Run this script in root project dir
# Kill existing emulator
$ANDROID_HOME/platform-tools/adb devices | grep emulator | cut -f1 | while read line; do $ANDROID_HOME/platform-tools/adb -s $line emu kill; done
# Install system image
$ANDROID_HOME/tools/bin/sdkmanager "system-images;android-27;google_apis;x86"
yes | $ANDROID_HOME/tools/bin/sdkmanager --licenses
# Create emulator
echo "no" | $ANDROID_HOME/tools/bin/avdmanager create avd -f \
-n "tester" \
-k 'system-images;android-27;google_apis;x86' \
-b x86 \
-d "Nexus 5X"
# Start emulator
$ANDROID_HOME/emulator/emulator -avd tester &
# Wait for emulator to start
$ANDROID_HOME/platform-tools/adb wait-for-device shell input keyevent 82
while [ "`$ANDROID_HOME/platform-tools/adb shell getprop sys.boot_completed | tr -d '\r' `" != "1" ] ; do sleep 1; done
sleep 5;
I get an error when using google_apis_playstore
because it can't adb in to check if the emulator has started because of the dialog.
error: device unauthorized.
This adb server's $ADB_VENDOR_KEYS is not set
Try 'adb kill-server' if that seems wrong.
Otherwise check for a confirmation dialog on your device.
Seems silly that you would need to accept debugging permissions for an emulator?
Edit: I have submitted this as a bug https://issuetracker.google.com/issues/128271326
adb shell input keyevent
after emulator booted. Similarlysdkmanager --licenses
should be accepted before downloading. – Cecum