Shot icon indicating copy to clipboard operation
Shot copied to clipboard

Saving screenshots results in permission denied error.

Open davidliu opened this issue 4 years ago • 4 comments

Expected behaviour

Saving screenshots saves properly.

Actual behaviour

Test fails with the following stack trace.

E/TestRunner: java.io.IOException: Permission denied
        at java.io.UnixFileSystem.createFileExclusively0(Native Method)
        at java.io.UnixFileSystem.createFileExclusively(UnixFileSystem.java:317)
        at java.io.File.createNewFile(File.java:1008)
        at com.karumi.shot.compose.ScreenshotSaver.createFileIfNotExists(ScreenshotSaver.kt:77)
        at com.karumi.shot.compose.ScreenshotSaver.saveScreenshotBitmap(ScreenshotSaver.kt:59)
        at com.karumi.shot.compose.ScreenshotSaver.saveScreenshot(ScreenshotSaver.kt:21)
        at com.karumi.shot.compose.ComposeScreenshot.saveScreenshot(ComposeScreenshot.kt:22)
        at com.karumi.shot.ScreenshotTest$DefaultImpls.compareScreenshot(ScreenshotTest.kt:144)

Steps to reproduce

  1. Sample repo provided here: https://github.com/davidliu/ShotSaveBug
  2. Run test.

Notably, the screenshot dirs are not created (the mkdirs fails with a false return value).

Version of the library

5.10.5

davidliu avatar May 19 '21 12:05 davidliu

@davidliu I think you might be missing

    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>

in the test app manifest. This solved a similar issue for me

FrancoisBlavoet avatar May 27 '21 01:05 FrancoisBlavoet

That doesn't work as of 5.10.5. According to the instructions, this shouldn't be needed either any more.

davidliu avatar May 27 '21 02:05 davidliu

Hey @davidliu I've tested the repository you shared with me and it looks like Shot is working as expected. My intuition tells me you didn't configure the device as expected. Using the scripts you can find in shot-consumer sample project I've started an emulator and recorded the screenshots as expected. Could you please ensure your device has an SD card associated with enough space? If it is not working, please share with us the device config you are using so we can reproduce the error. Thank you in advance.

pedrovgs avatar Jul 01 '21 06:07 pedrovgs

@davidliu I had this issue as well. Turned out the virtual sd card was out of space, deleting the screenshots on the sdcard fixed the issue for me.

AndrewReitz avatar Nov 07 '23 16:11 AndrewReitz