allure-framework / allure-kotlin

Allure integrations for test frameworks targeting Kotlin and Java with 1.6 source compatibility.
Apache License 2.0
56 stars 21 forks source link

Could not create Allure results directory for Android SDK 30 (and couldn't write allure-results if dir exists) #41

Closed SergKhram closed 3 years ago

SergKhram commented 3 years ago

SDK 30 Manifest: uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE"/ uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/ uses-permission android:name="android.permission.INTERNET"/ uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/ uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" / uses-permission android:name="android.permission.ACCESS_MEDIA_LOCATION" / uses-feature android:name="android.hardware.location.gps" />

application android:requestLegacyExternalStorage="true" ...`

But we have the error: io.qameta.allure.kotlin.AllureResultsWriteException: Could not create Allure results directory at io.qameta.allure.kotlin.FileSystemResultsWriter.createDirectories(FileSystemResultsWriter.kt:61) at io.qameta.allure.kotlin.FileSystemResultsWriter.write(FileSystemResultsWriter.kt:42) at io.qameta.allure.kotlin.AllureLifecycle.writeAttachment(AllureLifecycle.kt:497) at io.qameta.allure.kotlin.AllureLifecycle.addAttachment(AllureLifecycle.kt:453) at io.qameta.allure.kotlin.Allure.attachment(Allure.kt:261) at io.qameta.allure.android.AllureScreenshotKt.allureScreenshot(AllureScreenshot.kt:34) at io.qameta.allure.android.AllureScreenshotKt.allureScreenshot$default(AllureScreenshot.kt:25) at io.qameta.allure.android.rules.ScreenshotRule$apply$1.evaluate(ScreenshotRule.kt:24) at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306) at org.junit.runners.BlockJUnit4ClassRunner$1.evaluate(BlockJUnit4ClassRunner.java:100) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:63) at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329) at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293) at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306) at org.junit.runners.ParentRunner.run(ParentRunner.java:413) at org.junit.runners.Suite.runChild(Suite.java:128) at org.junit.runners.Suite.runChild(Suite.java:27) at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329) at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293) at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306) at org.junit.runners.ParentRunner.run(ParentRunner.java:413) 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:395) at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:2205)

If we create the directory - after tests we see empty allure-results dir with error Read-only file system

Malinskiy commented 3 years ago

Android 30 ignores all flags for legacy storage requests.

You have to give permissions to get out of the isolated storage similar to this

which is basically what the official docs suggest

TL;DR adb shell appops set --uid PACKAGE_NAME MANAGE_EXTERNAL_STORAGE allow

SergKhram commented 3 years ago

thx!