firebase / firebase-testlab-instr-lib

Apache License 2.0
13 stars 17 forks source link

FirebaseScreenCaptureProcessor fails to create `/sdcard/screenshots` in API 29 devices due to scoped storage #7

Closed sushantchoudhary closed 3 years ago

sushantchoudhary commented 4 years ago

Sample error :

09-07 20:18:56.627: E/ScreenshotWatcher(25480): Failed to capture screenshot 09-07 20:18:56.627: E/ScreenshotWatcher(25480): java.io.IOException: The directory /sdcard/screenshots does not exist and could not be created or is not writable. 09-07 20:18:56.627: E/ScreenshotWatcher(25480): at androidx.test.runner.screenshot.BasicScreenCaptureProcessor.process(BasicScreenCaptureProcessor.java:72) 09-07 20:18:56.627: E/ScreenshotWatcher(25480): at androidx.test.runner.screenshot.ScreenCapture.process(ScreenCapture.java:144) 09-07 20:18:56.627: E/ScreenshotWatcher(25480): at com.atlassian.android.jira.core.testutil.rule.ScreenshotWatcher.captureScreenshot(ScreenshotWatcher.kt:29) 09-07 20:18:56.627: E/ScreenshotWatcher(25480): at com.atlassian.android.jira.core.testutil.rule.ScreenshotWatcher.failed(ScreenshotWatcher.kt:19) 09-07 20:18:56.627: E/ScreenshotWatcher(25480): at

Cause : https://developer.android.com/training/data-storage#scoped-storage

Temp fix : https://developer.android.com/training/data-storage/use-cases#opt-out-scoped-storage

Starting with Android 11, ^ workaround will stop working.

eduardbosch commented 3 years ago

@sushantchoudhary how do you specify the no-isolated-storage option to run the tests? Either in Android Studio and with CI?

I've added the argument in the run configuration, but it keeps throwing the exception The directory /sdcard/screenshots does not exist and could not be created or is not writable.

Screenshot 2021-09-09 at 14 41 50

rodor87 commented 2 years ago

Starting with Android 11, ^ workaround will stop working.

Hi @sushantchoudhary @eduardbosch

What does this mean exactly? I am getting this error in Android 11. How can we get screenshots displayed in Firebase Test Lab reports in Android 11?

Thanks

austin226 commented 2 years ago

I was able to grant my test runner access to the /sdcard/screenshots directory in Android 11 by using the ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION intent. See https://stackoverflow.com/a/66968986.

I then used UiAutomator to grant the permission in the settings activity that appears.

stankinzl commented 1 year ago

The workaround is not working for me..