I’m automating the creation of screenshots using instrumented tests (androidTest
) on a debug version of my app using UiAutomator and a shell script that uses adb pull
.
Once each screenshot has been taken, I need to be given access to a directory to write each image to, that:
- can be written to without user input (eg requesting permissions, file picker)
- can be accessed by ADB without any special tricks that may break in future or on devices that haven’t been specially configured (eg run-as, rooting the device).
- doesn’t require any third-party tools (eg better adb sync)
- only has to work on Android devices with API 26 and later (8.0+).
- preferably does not require any manifest permissions (but this is not a deal-breaker).
The Android docs for choosing a storage API are centred around normal usage by a user of the production app, and don’t specify whether adb can access them.
There is so much outdated advice (thanks to the many, many breaking changes to the Android storage APIs over the last 10 years) that the signal-to-noise ratio for existing advice is very low, and checking whether each found solution still works is non-trivial.
Which storage API should/can I use that satisfies the above requirements?