pedrovgs/Shot

Screenshot Testing Not Working on Physical Device

Open

#276 opened on Jan 13, 2022

 (4 comments) (0 reactions) (0 assignees)Kotlin (111 forks)github user discovery
bughelp wanted

Repository metrics

Stars
 (1,208 stars)
PR merge metrics
 (No merged PRs in 30d)

Description

Expected behaviour

Run ./gradlew app:executeScreenshotTests -Precord on a physical device without any errors.

Actual behaviour

I am getting this error:

> Configure project :app
ComposeOptions.kotlinCompilerVersion is deprecated. Compose now uses the kotlin compiler defined in your buildscript.
Shot ADB warning: rm: /storage/emulated/0/Download/screenshots/package.uid/screenshots-default/: No such file or directory
Shot ADB warning: rm: /storage/emulated/0/Download/screenshots/package.uid/screenshots-compose-default/: No such file or directory

> Task :app:connectedDebugAndroidTest
Starting 2 tests on moto g(7) power - 10

package.ProfileScreenshotTest > rendersProfileScreen[moto g(7) power - 10] FAILED 
        java.io.IOException: No such file or directory
        at java.io.UnixFileSystem.createFileExclusively0(Native Method)

> Task :app:connectedDebugAndroidTest FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:connectedDebugAndroidTest'.
> There were failing tests. See the report at: file:///home/myUser/Projects/my-app/app/build/reports/androidTests/connected/index.html

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/7.0.2/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 15s
60 actionable tasks: 2 executed, 58 up-to-date

Version of the library

Version 5.12.2 I am using a physical smartphone with Android 10. The command ./gradlew app:executeScreenshotTests -Precord works fine on emulators using Android API 28 and 30.

I tried to enable WRITE_EXTERNAL_STORAGE, READ_EXTERNAL_STORAGE and requestLegacyExternalStorage but it doesn't work. Also, I enabled to force storage permission on developer options. I also enabled the access to non-SDK interfaces:

adb shell settings put global hidden_api_policy_p_apps 1 && adb shell settings put global hidden_api_policy_pre_p_apps 1 && adb shell settings put global hidden_api_policy 1

Nothing worked for me. Does anyone know how to fix it?

Contributor guide