Shot
Shot copied to clipboard
Saving screenshots results in permission denied error.
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
- Sample repo provided here: https://github.com/davidliu/ShotSaveBug
- 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 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
That doesn't work as of 5.10.5. According to the instructions, this shouldn't be needed either any more.
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.
@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.