Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

metadata.json: No such file or directory #296

Open
PawelKwiecinski opened this issue Oct 7, 2021 · 2 comments
Open

metadata.json: No such file or directory #296

PawelKwiecinski opened this issue Oct 7, 2021 · 2 comments

Comments

@PawelKwiecinski
Copy link

I'm trying to add screenshot testing using screenshot-tests-for-android and ran into an issue where I cannot get it to work. The error I get:

ls: /sdcard/screenshots/com.xyz.test/screenshots-default/metadata.json: No such file or directory
ls: /data/data/com.xyz.test/app_screenshots-default/metadata.json: No such file or directory

The tests live is a library module. Test uses androidx.fragment.app.testing.launchFragmentInContainer, then waits for it and calls Screenshot.snapActivity(fragment.activity!!). I use a custom test runner configured exactly as in the docs to call onCreate + onDestroy. Tests Use Junit4 + Espresso. The screenshot files themselves get generated, saved and pulled correctly. But the whole thing fails because of the missing metadata.

Things I've tried:

  • with/without orchestrator
  • check logcat (nothing related to the issue there)
  • use snap(fragment!!.view) -> same issue
  • add all the test data by hand using setName(), etc
  • use different API level emulators: 28,29,27
  • make sure both lib AndroidManifest.xml and test AndroidManifest.xml have WRITE_EXTERNAL_STORAGE permission
  • probably couple other things I've forgot
@oradkovsky
Copy link

With what I believe is a similar setup (aar + sample app), I ended up putting tests into sample app. My manifest under sample/androidTest not only has WRITE_EXTERNAL_STORAGE, but also package (ending with test) and android:sharedUserId (ending with uid) - something sample app also has in its manifest. The above works for me under API28. APIs beyond come with scoped storage, but it's another story.

@xiphirx
Copy link
Contributor

xiphirx commented Feb 2, 2022

This typically indicates that you're not calling flush() appropriately like so:

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants