BPDev
BPDev

Reputation: 877

Fastlane with Compose - [!] No screenshots were detected 📷❌

Is there a working example of using Jetpack Compose with Fastlane screenshots?

When I try it, I get a "No screenshots were detected" error.

@RunWith(AndroidJUnit4::class)
class ScreenshotTest {

    @get:Rule
    val composeTestRule = createComposeRule()

    @Before
    fun init() {
        Screengrab
            .setDefaultScreenshotStrategy(
                UiAutomatorScreenshotStrategy()
            )
    }

    @Test
    fun useAppContext() {
        Screengrab.screenshot("before");

        composeTestRule.setContent {
            FastlaneTestTheme {
                MainScreen()
            }
        }

        Screengrab.screenshot("after");
    }
}

repo

_@_-MacBook-Pro FastlaneTest % ./gradlew assembleDebug assembleAndroidTest

BUILD SUCCESSFUL in 2s
56 actionable tasks: 4 executed, 52 up-to-date
_@_-MacBook-Pro FastlaneTest % bundle exec fastlane screenshots
[✔] 🚀 
[12:38:54]: ------------------------------
[12:38:54]: --- Step: default_platform ---
[12:38:54]: ------------------------------
[12:38:54]: Driving the lane 'android screenshots' 🚀
[12:38:54]: -----------------------------------------
[12:38:54]: --- Step: capture_android_screenshots ---
[12:38:54]: -----------------------------------------
[12:38:54]: Successfully loaded '/Users/_/AndroidStudioProjects/FastlaneTest/fastlane/Screengrabfile' 📄

+-----------------------------------------------------------------------+
|           Detected Values from './fastlane/Screengrabfile'            |
+-----------------------------+-----------------------------------------+
| test_instrumentation_runner | androidx.test.runner.AndroidJUnitRunner |
+-----------------------------+-----------------------------------------+


+-----------------------------------------------------------------------+
|                     Summary for screengrab 1.0.0                      |
+-----------------------------+-----------------------------------------+
| tests_package_name          | com.test.fastlane.test                  |
| android_home                | /Users/_/Library/Android/sdk     |
| locales                     | ["en-US"]                               |
| clear_previous_screenshots  | false                                   |
| output_directory            | fastlane/metadata/android               |
| skip_open_summary           | false                                   |
| app_package_name            | com.test.fastlane                       |
| test_instrumentation_runner | androidx.test.runner.AndroidJUnitRunner |
| ending_locale               | en-US                                   |
| device_type                 | phone                                   |
+-----------------------------+-----------------------------------------+

[12:38:54]: Limiting the test classes run by `screengrab` to just those that generate screenshots can make runs faster.
[12:38:54]: Consider using the :use_tests_in_classes or :use_tests_in_packages option, and organize your tests accordingly.
[12:38:54]: $ adb devices -l
[12:38:54]: ▸ List of devices attached
[12:38:54]: ▸ emulator-5554          device product:sdk_gphone64_arm64 model:sdk_gphone64_arm64 device:emu64a transport_id:2
[12:38:54]: $ adb -s emulator-5554 shell echo \$EXTERNAL_STORAGE
[12:38:54]: ▸ /sdcard
[12:38:54]: Cleaning screenshots on device
ls: /sdcard/com.test.fastlane/screengrab: No such file or directory
[12:38:54]: Exit status: 1
ls: /data/data/com.test.fastlane/app_screengrab: Permission denied
[12:38:54]: Exit status: 1
[12:38:54]: To not be asked about this value, you can specify it using 'app_apk_path'
[12:38:54]: Select your debug app APK
1. app/build/intermediates/apk/androidTest/debug/app-debug-androidTest.apk
2. app/build/intermediates/apk/debug/app-debug.apk
3. app/build/outputs/apk/androidTest/debug/app-debug-androidTest.apk
4. app/build/outputs/apk/debug/app-debug.apk
?  4
[12:39:00]: To not be asked about this value, you can specify it using 'tests_apk_path'
[12:39:00]: Select your debug tests APK
1. app/build/intermediates/apk/androidTest/debug/app-debug-androidTest.apk
2. app/build/intermediates/apk/debug/app-debug.apk
3. app/build/outputs/apk/androidTest/debug/app-debug-androidTest.apk
4. app/build/outputs/apk/debug/app-debug.apk
?  3
[12:39:02]: Validating app APK
[12:39:02]: $ /Users/_/Library/Android/sdk/build-tools/34.0.0/aapt dump permissions app/build/outputs/apk/debug/app-debug.apk
[12:39:02]: ▸ package: com.test.fastlane
[12:39:02]: ▸ uses-permission: name='android.permission.DISABLE_KEYGUARD'
[12:39:02]: ▸ uses-permission: name='android.permission.WAKE_LOCK'
[12:39:02]: ▸ uses-permission: name='android.permission.WRITE_EXTERNAL_STORAGE'
[12:39:02]: ▸ uses-permission: name='android.permission.READ_EXTERNAL_STORAGE'
[12:39:02]: ▸ uses-permission: name='android.permission.CHANGE_CONFIGURATION'
[12:39:02]: ▸ permission: com.test.fastlane.DYNAMIC_RECEIVER_NOT_EXPORTED_PERMISSION
[12:39:02]: ▸ uses-permission: name='com.test.fastlane.DYNAMIC_RECEIVER_NOT_EXPORTED_PERMISSION'
[12:39:02]: Installing app APK
[12:39:02]: $ adb -s emulator-5554 install -r app/build/outputs/apk/debug/app-debug.apk
[12:39:02]: ▸ Performing Streamed Install
[12:39:03]: ▸ Success
[12:39:03]: Installing tests APK
[12:39:03]: $ adb -s emulator-5554 install -r app/build/outputs/apk/androidTest/debug/app-debug-androidTest.apk
[12:39:03]: ▸ Performing Streamed Install
[12:39:03]: ▸ Success
[12:39:03]: Granting the permission necessary to change locales on the device
[12:39:03]: $ adb -s emulator-5554 shell pm grant com.test.fastlane android.permission.CHANGE_CONFIGURATION
[12:39:03]: $ adb -s emulator-5554 shell getprop ro.build.version.sdk
[12:39:03]: ▸ 34
[12:39:03]: Granting the permissions necessary to access device external storage
[12:39:03]: $ adb -s emulator-5554 shell pm grant com.test.fastlane android.permission.WRITE_EXTERNAL_STORAGE
[12:39:03]: $ adb -s emulator-5554 shell pm grant com.test.fastlane android.permission.READ_EXTERNAL_STORAGE
[12:39:03]: Running tests for locale: en-US
[12:39:03]: $ adb -s emulator-5554 shell am instrument --no-window-animation -w \
-e testLocale en_US \
-e endingLocale en_US \
com.test.fastlane.test/androidx.test.runner.AndroidJUnitRunner
[12:39:05]: ▸ com.test.fastlane.ScreenshotTest:s_glBindAttribLocation: bind attrib 0 name position
[12:39:05]: ▸ s_glBindAttribLocation: bind attrib 1 name color
[12:39:05]: ▸ s_glBindAttribLocation: bind attrib 2 name localCoord
[12:39:06]: ▸ .
[12:39:06]: ▸ Time: 1.45
[12:39:06]: ▸ OK (1 test)
[12:39:06]: Pulling captured screenshots from the device
ls: /sdcard/com.test.fastlane/screengrab: No such file or directory
[12:39:06]: Exit status: 1
ls: /data/data/com.test.fastlane/app_screengrab: Permission denied
[12:39:06]: Exit status: 1
[12:39:06]: Make sure you've used Screengrab.screenshot() in your tests and that your expected tests are being run.
+----------------------------------------+
|              Lane Context              |
+------------------+---------------------+
| DEFAULT_PLATFORM | android             |
| PLATFORM_NAME    | android             |
| LANE_NAME        | android screenshots |
+------------------+---------------------+
[12:39:06]: No screenshots were detected 📷❌

+--------------------------------------------------+
|                 fastlane summary                 |
+------+-----------------------------+-------------+
| Step | Action                      | Time (in s) |
+------+-----------------------------+-------------+
| 1    | default_platform            | 0           |
| 💥   | capture_android_screenshots | 11          |
+------+-----------------------------+-------------+

[12:39:06]: fastlane finished with errors

[!] No screenshots were detected 📷❌

There is an old issue, but there are also recent articles about framing screenshots.


✅ fastlane environment ✅

Stack

Key Value
OS 14.2.1
Ruby 2.6.10
Bundler? true
Git git version 2.43.0
Installation Source /usr/local/bin/fastlane
Host macOS 14.2.1 (23C71)
Ruby Lib Dir /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib
OpenSSL Version LibreSSL 3.3.6
Is contained false
Is homebrew false
Is installed via Fabric.app false
Xcode Path /Applications/Xcode.app/Contents/Developer/
Xcode Version 15.1
Swift Version 5.9.2

System Locale

Variable Value
LANG en_US.UTF-8
LC_ALL
LANGUAGE

fastlane files:

`./fastlane/Fastfile`
# This file contains the fastlane.tools configuration
# You can find the documentation at https://docs.fastlane.tools
#
# For a list of all available actions, check out
#
#     https://docs.fastlane.tools/actions
#
# For a list of all available plugins, check out
#
#     https://docs.fastlane.tools/plugins/available-plugins
#

# Uncomment the line if you want fastlane to automatically update itself
# update_fastlane

default_platform(:android)

platform :android do
  lane :screenshots do
    capture_android_screenshots
    # upload_to_play_store
  end

  desc "Runs all the tests"
  lane :test do
    gradle(task: "test")
  end

  desc "Submit a new Beta Build to Crashlytics Beta"
  lane :beta do
    gradle(task: "clean assembleRelease")
    crashlytics
  
    # sh "your_script.sh"
    # You can also use other beta testing services here
  end

  desc "Deploy a new version to the Google Play"
  lane :deploy do
    gradle(task: "clean assembleRelease")
    upload_to_play_store
  end
end

`./fastlane/Appfile`
json_key_file("") # Path to the json secret file - Follow https://docs.fastlane.tools/actions/supply/#setup to get one
package_name("com.test.fastlane") # e.g. com.krausefx.app

fastlane gems

Gem Version Update-Status
fastlane 2.217.0 ✅ Up-To-Date
screengrab 1.0.0 ✅ Up-To-Date

Loaded fastlane plugins:

No plugins Loaded

Loaded gems
Gem Version
did_you_mean 1.3.0
bundler 1.17.2
etc 1.0.1
forwardable 1.2.0
rake 13.1.0
rexml 3.2.6
CFPropertyList 3.0.6
public_suffix 5.0.4
addressable 2.8.6
artifactory 3.0.15
atomos 0.1.3
aws-eventstream 1.3.0
aws-partitions 1.873.0
aws-sigv4 1.8.0
jmespath 1.6.2
aws-sdk-core 3.190.1
aws-sdk-kms 1.75.0
aws-sdk-s3 1.142.0
babosa 1.0.4
claide 1.1.0
colored 1.2
colored2 3.1.2
highline 2.0.3
commander 4.6.0
declarative 0.0.20
digest-crc 0.6.5
unf_ext 0.0.9.1
unf 0.1.4
domain_name 0.5.20190701
dotenv 2.8.1
emoji_regex 3.2.3
excon 0.108.0
faraday-em_http 1.0.0
faraday-em_synchrony 1.0.0
faraday-excon 1.1.0
faraday-httpclient 1.0.1
multipart-post 2.3.0
faraday-multipart 1.0.4
faraday-net_http 1.0.1
faraday-net_http_persistent 1.2.0
faraday-patron 1.0.0
faraday-rack 1.0.0
faraday-retry 1.0.3
ruby2_keywords 0.0.5
faraday 1.10.3
http-cookie 1.0.5
faraday-cookie_jar 0.0.7
faraday_middleware 1.2.0
fastimage 2.3.0
gh_inspector 1.1.3
jwt 2.7.1
multi_json 1.15.0
os 1.1.4
signet 0.18.0
googleauth 1.8.1
httpclient 2.8.3
mini_mime 1.1.5
trailblazer-option 0.1.2
uber 0.1.0
representable 3.2.0
retriable 3.1.2
webrick 1.8.1
google-apis-core 0.11.2
google-apis-androidpublisher_v3 0.54.0
google-apis-playcustomapp_v1 0.13.0
google-apis-iamcredentials_v1 0.17.0
google-apis-storage_v1 0.29.0
google-cloud-env 1.6.0
google-cloud-errors 1.3.1
google-cloud-core 1.6.1
google-cloud-storage 1.45.0
json 2.7.1
mini_magick 4.12.0
naturally 2.2.1
optparse 0.1.1
plist 3.7.0
rubyzip 2.3.2
security 0.1.3
simctl 1.6.10
terminal-notifier 2.0.0
unicode-display_width 2.5.0
terminal-table 3.0.2
tty-screen 0.8.2
tty-cursor 0.7.1
tty-spinner 0.9.3
word_wrap 1.0.0
nanaimo 0.3.0
xcodeproj 1.23.0
rouge 2.0.7
xcpretty 0.3.0
xcpretty-travis-formatter 1.0.1

generated on: 2023-12-24

Upvotes: 1

Views: 142

Answers (0)

Related Questions