Status Update
Comments
ls...@google.com <ls...@google.com>
jg...@google.com <jg...@google.com>
ys...@google.com <ys...@google.com> #2
yu...@schimke.ee <yu...@schimke.ee> #3
pa...@google.com <pa...@google.com> #4
yu...@schimke.ee <yu...@schimke.ee> #5
yu...@schimke.ee <yu...@schimke.ee> #6
pa...@google.com <pa...@google.com> #7
ys...@google.com <ys...@google.com> #8
am...@google.com <am...@google.com> #9
Root cause is that Gradle will force Kotlin kotlin-stdlib-common to 1.3.72 when .kts
is used. As AGP recently started compiling against 1.4, and we ship bytecode that contains references to kotlin/KotlinNothingValueException
causing the issue. We need to change AGP to compile against 1.3.72.
This does not fail with Groovy build scripts as both 1.4 and 1.3.72 kotlin-stdlib-common end up in the classpath.
ys...@google.com <ys...@google.com> #10
am...@google.com <am...@google.com> #11
This isseu will get fixed in AGP 4.2.0-alpha09, as it got fixed by
However, there is still an issue of AGP compiling against 1.4 and running against 1.3.72 which must be fixed. Fixing that is tracked in
yu...@schimke.ee <yu...@schimke.ee> #12
yu...@schimke.ee <yu...@schimke.ee> #13
It should be out next week in case we do not find any major blockers.
am...@google.com <am...@google.com> #14
Is it to convert the build gradle file to Groovy?
yu...@schimke.ee <yu...@schimke.ee> #15
Once workaround is to add Kotlin 1.4.0 stdlib to buildSrc e.g update buildSrc/build.gradle.kts
with
dependencies {
implementation("org.jetbrains.kotlin:kotlin-stdlib:1.4.0")
}
yu...@schimke.ee <yu...@schimke.ee> #16
many thanks
ys...@google.com <ys...@google.com>
am...@google.com <am...@google.com> #17
For the above comment poster: In my project, I only had to change the top-level build files to .gradle
, and the subprojects .kts
build files I left alone. It fixed the issue for me.
yu...@schimke.ee <yu...@schimke.ee> #18
yu...@schimke.ee <yu...@schimke.ee> #19
am...@google.com <am...@google.com> #20
Sorry, I think we're discussing different things then. This bug was originally about the wrong background being used in Compose Previews that specify a wear device. That was already fixed. Can you please confirm if this is still an issue for you?
We can create another bug to start discussing the other issue you're talking about. I get the same as you when deploying the preview to a device, but I didn't understand your exact concern. Would you expect the background to be dark on the device as well? Or would you expect the Compose Preview to display a text composable showing a theme id?
Thanks!
yu...@schimke.ee <yu...@schimke.ee> #21
That makes sense. I started with the issue report for on device previews, as the title and the original reproduction explain.
1. Create an empty preview with a background in the annotation
2. View in Preview AS window
3. Click to preview on device (emulator)
Although I guess we split halfway through.
- a White default in the Android Studio window. The top two in the design view are white. But Wear themes default to Black.
- The run on emulator ignoring background. (The bottom two previews should both be blue)
am...@google.com <am...@google.com> #22
I see, thanks for clarifying and sorry for not realizing the goal of the original post.
In that case, issue #1 has been addressed and #2 is open, is that right?
In regards to #2, when deploying a Compose Preview to a device/emulator, we wrap the composable into PreviewActivity
PreviewActivity
. Deploying the preview was initially thought as a feature to cover scenarios that you could not check properly in interactive preview, e.g. interactions that trigger network requests, inflate other activities, etc. Accessing an activity/application resources was not something we had in mind when coming up with the feature.
To achieve what you want, you can call this composable from the setContent
method of a project activity, e.g. MainActivity
, right-click the activity name and click on Run <activity>
. This should deploy the app artifact (hence I expect you to be able to access resources normally) and inflate the activity in a similar manner then what deploy preview does.
yu...@schimke.ee <yu...@schimke.ee> #23
Thanks, I'm not actually blocked. We end up wrapping most of our Previews with the following, which is simpler.
Box(modifier = Modifier.background(Color.Black)) {
But as a developer if you have to do something different, be it add a background specifically in every preview, or use a different test activity and launcher, then it seems most developers will see an incorrect rendering on Wear. They might just end up putting a flat black background into their actual composable, when they should mostly be transparent and falling through to the device or screen background.
To be clear, I don't need to access resources in my preview. That was just to debug why I wasn't seeing the right background color. I don't get either the color specified in the Preview annotation, nor do I get the device default. A default white background is really disruptive for testing Wear composables.
Should I raise another issue specifically for this feature request (#2) and prioritization?
am...@google.com <am...@google.com> #24
Thanks for the context. We're aware of this limitation for deploying preview in general, not only for wear. We heard this feedback before about users being confused about theme and preview attributes not being applied to the deployed preview. If you don't mind, I'd prefer a new feature request to focus on #2, so we can better track/group all the issues related to that problem.
Thanks!
ys...@google.com <ys...@google.com> #25
am...@google.com <am...@google.com> #26
thanks!
Description
STEPS TO REPRODUCE:
1. Create an empty preview with a background in the annotation
2. View in Preview AS window
3. Click to preview on device (emulator)
```
@Preview(
device = Devices.WEAR_OS_LARGE_ROUND,
showSystemUi = true,
backgroundColor = 0xff222266,
showBackground = true,
group = "Devices - Large Round",
)
@Composable
fun MyPreview() {
}
```
ATTACH SCREENSHOTS/RECORDINGS OF THE ISSUE
------------------
IMPORTANT: Please read
all required information.
------------------
Studio Build:
Version of Gradle Plugin: 7.2.0
Version of Gradle: 7.4.2
Version of Java: Java 11
OS: Linux