Anyone know if there should still be issue doing c...
# compose
j
Anyone know if there should still be issue doing compose preview screenshot testing (https://developer.android.com/studio/preview/compose-screenshot-testing) where preview is using CMP composable that includes shared resource string for example? It works if that shared resource is not included.
m
Still not working for me with compose-plugin 1.7.0-beta02 I'm getting
java.lang.NoSuchMethodError: 'void org.jetbrains.compose.resources.ResourceItem.<init>(java.util.Set, java.lang.String, long, long)'
Thought might work after beta01 as the changlog mentioned Multiplatform resources being packed into Android assets
j
Android previews that include CMP code that in turn include shared resources does at least work now (that had been broken before).....issue seems to be then when using preview based screenshot testing with that setup
m
I would like to think that this is getting us one step closer to previews in common module 😄
k
Previews in the common module already work in the Fleet
m
It's not the same as Android Previews though
j
@Konstantin Tskhovrebov are there any plans to build out screenshot testing using that?
d
Android previews work with CMP resources since alpha07 or something. But Jetpack screenshot only work with the androidx preview annotation. My current setups is in commonMain create the preview with CMP annotation and preview parameter provider then in AndroidMain create a preview that calls the commonMain preview function. And for screenshots in the screenshot sourceset I just call the androidMain preview function. This allows you to have both previews Android/screenshot with the minimal lines of code
Also don't forget for preview parameter providers extend form both the androidx one and the CMP one so you can use the same provider for both commonMain and androidMain/screenshotTests
j
Are you using shared CMP resources? I've tried setup like that but still seeing issues
If I'm not using shared resources then it works fine
d
Think je also need to ensure you use the latest compose compiler plugin
j
I'm using the latest of everything
d
I'm using it with string resources
Also make sure. You do a clean build without buildcache
j
The fact that it works/doesn't work as I remove/add back share CMP resource string that shared composable is using makes me think that unlikely to be the issue in this case
sorry, missed your reply that you are using shared string resources
hmm
d
The resources are in the same module as the CMP commonMain/resources/values/strings.xml
j
yeah, same here
d
Also spend 2 days getting to work but the the solutions for me was using the latest alpha/beta version.
Strings work but on fonts require you to also initialize them in androidMain
j
I'm using dependencies shown in following....that also contains updates to restructure previews along lines of what you described above https://github.com/joreilly/Confetti/pull/1431/files
and then running
./gradlew :androidApp:updateDebugScreenshotTest
for example
d
Maybe check line 194 of shared/build.gradle since with compose recourse don't think you have to set that for android
j
which generates 1x1 pixel image
getting same after commenting that out
d
Also do check if you are using the correct compose compiler thought that version didn't match up with the actual compose multiplatform version number
Don't have access to my laptop so can't check now
The compiler was like alpha02 and the other CMP dependencies where already beta
I also have
Copy code
buildFeatures {
    buildConfig = false
    compose = true
}
j
tried on another project and seeing same issue as @Muaz KADAN in that one....but again only if I include shared CMP string in the composable....if I don't include it then it works fine
Copy code
java.lang.NoSuchMethodError: 'void org.jetbrains.compose.resources.ResourceItem.<init>(java.util.Set, java.lang.String, long, long)'
I've merged changes made so far in that project in case anyone wants to try it out (https://github.com/joreilly/FantasyPremierLeague). Can replicate by running
updateScreenshotTests
gradle task If you swap around following in
PlayerDetailsViewShared
then it works
Copy code
PlayerStatView(stringResource(Res.string.team),  player.team)
/PlayerStatView("Team",  player.team)
looks like there was a
0.0.1-alpha07
release of screenshot testing plugin on Friday....it doesn't fix the issue but at least it does report a failure when this happens
Has anyone by chance had any success doing this after that?
@ppvi this was the issue I was referring to in that bluesky thread. As mentioned it may very likely be issue with some other component but just in case you knew of any workaround etc. It would be very cool capability to have if it worked in this scenario.
j
Did you ever manage to get past this issue? Hitting the same one now...
198 Views