Android 10. Unable to take a screenshot by FailshotRule().
Not reproduced on Android <=9
Log: java.io.IOException: Permission denied at java.io.UnixFileSystem.createFileExclusively0(Native Method) at java.io.UnixFileSystem.createFileExclusively(UnixFileSystem.java:317) at java.io.File.createTempFile(File.java:2018) at kotlin.io.FilesKt__UtilsKt.createTempFile(Utils.kt:49) at io.qameta.allure.espresso.utils.AttachmentUtilsKt.createAttachmentFile(AttachmentUtils.kt:7) at io.qameta.allure.espresso.ScreenshotKt.deviceScreenshot(Screenshot.kt:14) at io.qameta.allure.espresso.FailshotRule.failshot(FailshotRule.kt:26) at io.qameta.allure.espresso.FailshotRule.access$failshot(FailshotRule.kt:11) at io.qameta.allure.espresso.FailshotRule$apply$1.evaluate(FailshotRule.kt:18) at androidx.test.rule.GrantPermissionRule$RequestPermissionStatement.evaluate(GrantPermissionRule.java:134) at androidx.test.rule.ActivityTestRule$ActivityStatement.evaluate(ActivityTestRule.java:531) at androidx.test.rule.GrantPermissionRule$RequestPermissionStatement.evaluate(GrantPermissionRule.java:134) at org.junit.rules.RunRules.evaluate(RunRules.java:20) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at org.junit.runners.Suite.runChild(Suite.java:128) at org.junit.runners.Suite.runChild(Suite.java:27) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at org.junit.runner.JUnitCore.run(JUnitCore.java:137) at org.junit.runner.JUnitCore.run(JUnitCore.java:115) at androidx.test.internal.runner.TestExecutor.execute(TestExecutor.java:56) at androidx.test.runner.AndroidJUnitRunner.onStart(AndroidJUnitRunner.java:392) at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:2202)
Yep, it only reproduces with devices >= SDK 29. Android changed way to access external storage. So not only screenshots, but all attachments are affected. Can easily reproduce it by running allure-android tests on simulator (for example, Pixel 3 with SDK 29) - tests will fail.
A bit tricky one. I was thinking about fixing it in scope of that PR: https://github.com/allure-framework/allure-android/pull/52
But since nobody was complaining (and still not sure that PR is needed at all), skipped that part :)
Hi @dkorobtsov
I'm looking for a tool to generate reports and take screenshots. Allure seems to be a great one. I have made some tests with other tools and I got the same issue. None of these tools are fixing this so far. Then, It will be great if allure had it fixed.
So, have you fixed it in #52 ? or will it be fixed in the future?
@leandrofnjr not yet, makes sense to do separate PR, but I will try to find time to do a fix it in the nearest feature (if nobody else does that earlier). :) Problem is - starting from SDK >= 29 Android completely changed way to work with storage - it no longer allows to save directly to external storage. Does not look like complicated fix, but still will require to do some changes. I guess instead of storing everything on sdcard, will have to use different storage types based on attachment content.