Status Update
Comments
di...@google.com <di...@google.com>
da...@raileasy.co.uk <da...@raileasy.co.uk> #2
I ran into this too in our project. For us, it seemed to be caused when using lifecycleScope.launch {}
inside of a LifecycleResumeEffect
.
var secondsUntilRefresh by rememberSaveable { mutableIntStateOf(refreshInterval) }
LifecycleResumeEffect(secondsUntilRefresh) {
val job =
lifecycleScope.launch {
if (secondsUntilRefresh > 0) {
delay(1000)
secondsUntilRefresh--
} else if (secondsUntilRefresh == 0) {
onRefresh()
}
}
// Don't count down in perpetuity
onPauseOrDispose { job.cancel() }
}
I worked around this by just not even trying to run this job during previews as it wasn't important for that anyway. Wrapped in a if (!LocalInspectionMode.current)
, screenshots generate fine.
di...@google.com <di...@google.com>
jg...@google.com <jg...@google.com>
an...@google.com <an...@google.com> #3
Thank you for your patience while our engineering team worked to resolve this issue. A fix for this issue is now available in:
- Android Studio Meerkat Feature Drop | 2024.3.2 Canary 4
- Android Gradle Plugin 8.10.0-alpha04
We encourage you to try the latest update.
If you notice further issues or have questions, please file a new bug report.
Thank you for taking the time to submit feedback — we really appreciate it!
tn...@google.com <tn...@google.com> #4
I'm assuming this fix isn't included in Studio but instead the screenshot AGP plugin; is that one released automatically at the same Studio cadence? If so, which version? Clicking around a bit on maven.google.com, I only see bits from back in November. What would it take for us to have this distributed automatically like the rest of the SDK libraries?
di...@google.com <di...@google.com> #5
It will be available in the next version of the plugin. It will be released manually once the required maven libraries (with the latest changes) are published. We do not want to release this automatically just yet. The end goal is to make it part of AGP and Studio
Description
I'm having difficulty getting screenshot testing to work.
When I run the
updateDebugScreenshotTest
target, the build fails with a message from Kotlin coroutines:I've tried various things to make this work. But ultimately, I don't think I should have to do anything special to make this work: the app runs fine on a device, and screenshot previews do work fine inside the IDE. So there must be something wrong with the way we're transferring the dependency graph used by the IDE to the screenshot task, or something like that.
I've made my sample project available here:https://drive.google.com/file/d/1YIDqlLa1R1HWzzZ43pPGyCLM1bXfliTK/view?usp=sharing . The project doesn't make a lot of sense -- I've stripped it down from a real project -- but it reproduces this exact problem; you can open it up in Studio and see the preview, and you can build the project, but the update screenshot task fails with the full exception: