Automatic screenshot capture of the running androi

2019-04-10 20:37发布

问题:

I've batchly generated a lot of apk install package, and I need to commit them to the android app store. Since the app store requires me to provide 3~4 pictures of the screenshot for the running application, and I don't wanna do this manually. So I'm trying to use some automation script. After some research I get the MIT sikuli UI interactive programming IDE which supports JPython.

The problem I got is that I need to uninstall my previously installed app or the installation process would fail with the "INSTALL_FAILED_INSUFFICIENT_STORAGE" error. I think the best way would be to run the uninstallation in the command line, and here comes the problem. The package name of the generated batched apks all starts with some same token, let's say "com.abc.efg", while differs with some minor numbers like "com.abc.efg_123_353" or "com.abc.efg_134_324", so I'm turning to some wild-char solution like "adb uninstall com.abc.efg*", but wild-char seems not be supported with the "adb" like command set. Any clue for this?

回答1:

An easier solution to take screeenshots without needing to do any compilation as david's solution required (for ICS devices only) is to use the following from the command line:

adb shell /system/bin/screencap -p /sdcard/screenshot.png
adb pull /sdcard/screenshot.png screenshot.png

This'll save the screenshot.png file in the current directory.

Tested on a Samsung Galaxy SII running 4.0.3.



回答2:

I've solved this with little trick. I preserve the previous installed package postfix, and every time I need to install a new one, I just call "adb uninstall" to remove the previous installed apk. As to the screenshot for the android device(emulator) in the command line, here is the solution by some guy.