Issue
So I have an idea of testing my android app on my laptop using one avd but with multiple config.ini files to change the makeup of the avd itself.
I have created multiple avds, and copied the config.ini files into a separate folder.
I have also written a bash script to
- loop through my config.ini files
- copy them one at a time to the avd folder (overwriting the last one)
- attempt to stop any current running emulator (this is my big problem)
- start the emulator
- run my tests on it (which take screenshots)
- adb pull the screenshots off into a folder
- start again with the next ini file
So I have most of this working, but I can't for the life of me stop/start/restart the avd.
I've tried multiple things from various SO questions including, but not limited to
- adb emu kill
- telnet kill
- adb shell stop
- pgrep emulator -f (to find the pid) then kill -9 to stop it
nothing seems to work properly, regularly without either locking my script, or leaving some remnant files meaning I can't start the emulator again.
This seems like it should be so easy and a great way to run my app on multiple device emulators without having to have them all running at once, something which my laptop would never be able to handle (it could do maybe 3 at once)
Solution
Do this on a (linux) shell:
adb shell su -c 'svc power shutdown' && echo "target has shut down"
Or maybe you have to do it "rooted", like this:
adb root && adb shell 'svc power shutdown' && echo "target has shut down"
It will shutdown the target (properly shows the "system powerdown" window inside emulation) and then also closes the emulator window. No stale lockfile left behind.
Of course after launching your target you will have to wait for this until the target has booted properly and accepts such adb shell commands.
Just tested it on emulated target android API 19 (kitkat) - worked nicely.
I hope it solves your idea of remote scripting your setup of multiple targets.
Answered By - tverrbjelke
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.