Status Update
Comments
rm...@google.com <rm...@google.com> #2
gh...@google.com <gh...@google.com> #3
Our team is also running into this because we use kotlin reflection to set up mock data for previews.
Can you suggest any workaround that we can apply locally to make layout lib include kotlin reflect until it is officially fixed? We are obviously including it as a build dependency but the layout lib preview doesn't pick it up for some reason.
cm...@google.com <cm...@google.com> #4
I do not see this issue in Electric Eel Beta 4, but I do see it in Flamingo Canary 6.
va...@gmail.com <va...@gmail.com> #5
I do not see this issue in Electric Eel Beta 4, but I do see it in Flamingo Canary 6.
Is it with the very same project? I'm trying to rule out whether this is related to specific library/compiler versions.
Thanks!
eu...@gmail.com <eu...@gmail.com> #6
Yes, that was with the same project. I can double check with the latest versions of each IDE and get back to you though.
cm...@google.com <cm...@google.com> #7
Correction: I was either mistaken before, or behavior has changed, but I am now getting the KotlinReflectionNotSupportedError
issue for IDE compose previews in both EE Beta 5 and Flamingo Canary 8.
Kotlin 1.6.21 AGP 7.3
va...@gmail.com <va...@gmail.com> #8
ja...@gmail.com <ja...@gmail.com> #9
cm...@google.com <cm...@google.com> #10
Diego, this looks to be the same problem as
eu...@gmail.com <eu...@gmail.com> #11
This looks to be the same as
ta...@gmail.com <ta...@gmail.com> #12
I'm pretty sure the failure is in locating kotlin.reflect.jvm.internal.ReflectionFactoryImpl
in
That Class.forName
should redirect to the "renamed" version that we move in the classpath to the layoutlib.internal so it loads the correct JVM version in
ja...@gmail.com <ja...@gmail.com> #13
The fix for this will be in a future canary of Flamingo.
eu...@gmail.com <eu...@gmail.com> #14
I'm on Flamingo 2022.2.1 Patch 1 and this isn't working quite right...Preview does not report any errors specific to Kotlin reflection anymore and will generate a preview, but it's as if the kotlin-reflect library was never loaded. For instance, given sealed class Foo
, calling Foo::class.isSealed
in a Preview Composable returns false, yet returns true when called in a Composable running on a physical device.
ja...@gmail.com <ja...@gmail.com> #15
I noticed this as well, and created this issue
cm...@google.com <cm...@google.com> #16
cm...@google.com <cm...@google.com> #17
Reopening as this doesn't seem to be fixed, according to multiple reports.
za...@gmail.com <za...@gmail.com> #18
I presume this is related, if not I can open a new issue.
For context, BackgroundUploadState
can be any sealed class or interface and the subclasses can be data object
s, object
s, or class
es and it makes no difference.
With this in a PreviewParameterProvider: BackgroundUploadState::class.sealedSubclasses
, I get the following Render Issue error:
java.lang.IndexOutOfBoundsException: Sequence doesn't contain element at index 0.
at _layoutlib_._internal_.kotlin.sequences.SequencesKt___SequencesKt$elementAt$1.invoke(_Sequences.kt:35)
at _layoutlib_._internal_.kotlin.sequences.SequencesKt___SequencesKt$elementAt$1.invoke(_Sequences.kt:35)
at _layoutlib_._internal_.kotlin.sequences.SequencesKt___SequencesKt.elementAtOrElse(_Sequences.kt:55)
at _layoutlib_._internal_.kotlin.sequences.SequencesKt___SequencesKt.elementAt(_Sequences.kt:35)
at androidx.compose.ui.tooling.PreviewUtils_androidKt.getPreviewProviderParameters(PreviewUtils.android.kt:62)
at androidx.compose.ui.tooling.ComposeViewAdapter$init$3$1$composable$1$1.invoke(ComposeViewAdapter.android.kt:508)
at androidx.compose.ui.tooling.ComposeViewAdapter$init$3$1$composable$1$1.invoke(ComposeViewAdapter.android.kt:502)
at androidx.compose.ui.tooling.ComposeViewAdapter$init$3$1.invoke(ComposeViewAdapter.android.kt:539)
at androidx.compose.ui.tooling.ComposeViewAdapter$init$3$1.invoke(ComposeViewAdapter.android.kt:497)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:109)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:35)
at androidx.compose.runtime.CompositionLocalKt.CompositionLocalProvider(CompositionLocal.kt:380)
at androidx.compose.ui.tooling.InspectableKt.Inspectable(Inspectable.android.kt:61)
at androidx.compose.ui.tooling.ComposeViewAdapter$WrapPreview$1.invoke(ComposeViewAdapter.android.kt:444)
at androidx.compose.ui.tooling.ComposeViewAdapter$WrapPreview$1.invoke(ComposeViewAdapter.android.kt:443)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:109)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:35)
at androidx.compose.runtime.CompositionLocalKt.CompositionLocalProvider(CompositionLocal.kt:380)
at androidx.compose.ui.tooling.ComposeViewAdapter.WrapPreview(ComposeViewAdapter.android.kt:438)
at androidx.compose.ui.tooling.ComposeViewAdapter.access$WrapPreview(ComposeViewAdapter.android.kt:124)
at androidx.compose.ui.tooling.ComposeViewAdapter$init$3.invoke(ComposeViewAdapter.android.kt:497)
at androidx.compose.ui.tooling.ComposeViewAdapter$init$3.invoke(ComposeViewAdapter.android.kt:494)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:109)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:35)
at androidx.compose.ui.platform.ComposeView.Content(ComposeView.android.kt:441)
at androidx.compose.ui.platform.AbstractComposeView$ensureCompositionCreated$1.invoke(ComposeView.android.kt:259)
at androidx.compose.ui.platform.AbstractComposeView$ensureCompositionCreated$1.invoke(ComposeView.android.kt:258)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:109)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:35)
at androidx.compose.runtime.CompositionLocalKt.CompositionLocalProvider(CompositionLocal.kt:380)
at androidx.compose.ui.platform.CompositionLocalsKt.ProvideCommonCompositionLocals(CompositionLocals.kt:216)
at androidx.compose.ui.platform.AndroidCompositionLocals_androidKt$ProvideAndroidCompositionLocals$3.invoke(AndroidCompositionLocals.android.kt:132)
at androidx.compose.ui.platform.AndroidCompositionLocals_androidKt$ProvideAndroidCompositionLocals$3.invoke(AndroidCompositionLocals.android.kt:131)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:109)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:35)
at androidx.compose.runtime.CompositionLocalKt.CompositionLocalProvider(CompositionLocal.kt:380)
at androidx.compose.ui.platform.AndroidCompositionLocals_androidKt.ProvideAndroidCompositionLocals(AndroidCompositionLocals.android.kt:121)
at androidx.compose.ui.platform.WrappedComposition$setContent$1$1$3.invoke(Wrapper.android.kt:155)
at androidx.compose.ui.platform.WrappedComposition$setContent$1$1$3.invoke(Wrapper.android.kt:154)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:109)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:35)
at androidx.compose.runtime.CompositionLocalKt.CompositionLocalProvider(CompositionLocal.kt:401)
at androidx.compose.ui.platform.WrappedComposition$setContent$1$1.invoke(Wrapper.android.kt:154)
at androidx.compose.ui.platform.WrappedComposition$setContent$1$1.invoke(Wrapper.android.kt:133)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:109)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:35)
at androidx.compose.runtime.ActualJvm_jvmKt.invokeComposable(ActualJvm.jvm.kt:97)
at androidx.compose.runtime.ComposerImpl.doCompose(Composer.kt:3593)
at androidx.compose.runtime.ComposerImpl.composeContent$runtime_release(Composer.kt:3520)
at androidx.compose.runtime.CompositionImpl.composeContent(Composition.kt:743)
at androidx.compose.runtime.Recomposer.composeInitial$runtime_release(Recomposer.kt:1114)
at androidx.compose.runtime.CompositionImpl.composeInitial(Composition.kt:649)
at androidx.compose.runtime.CompositionImpl.setContent(Composition.kt:635)
at androidx.compose.ui.platform.WrappedComposition$setContent$1.invoke(Wrapper.android.kt:133)
at androidx.compose.ui.platform.WrappedComposition$setContent$1.invoke(Wrapper.android.kt:124)
at androidx.compose.ui.platform.AndroidComposeView.setOnViewTreeOwnersAvailable(AndroidComposeView.android.kt:1597)
at androidx.compose.ui.platform.WrappedComposition.setContent(Wrapper.android.kt:124)
at androidx.compose.ui.platform.WrappedComposition.onStateChanged(Wrapper.android.kt:180)
at androidx.lifecycle.LifecycleRegistry$ObserverWithState.dispatchEvent(LifecycleRegistry.jvm.kt:320)
at androidx.lifecycle.LifecycleRegistry.addObserver(LifecycleRegistry.jvm.kt:198)
at androidx.compose.ui.platform.WrappedComposition$setContent$1.invoke(Wrapper.android.kt:131)
at androidx.compose.ui.platform.WrappedComposition$setContent$1.invoke(Wrapper.android.kt:124)
at androidx.compose.ui.platform.AndroidComposeView.onAttachedToWindow(AndroidComposeView.android.kt:1678)
at android.view.View.dispatchAttachedToWindow(View.java:21980)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3490)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3497)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3497)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3497)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3497)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3497)
at android.view.AttachInfo_Accessor.setAttachInfo(AttachInfo_Accessor.java:51)
at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:372)
at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:454)
at com.android.tools.idea.layoutlib.LayoutLibrary.createSession(LayoutLibrary.java:120)
at com.android.tools.rendering.RenderTask.createRenderSession(RenderTask.java:779)
at com.android.tools.rendering.RenderTask.lambda$inflate$6(RenderTask.java:927)
at com.android.tools.rendering.RenderExecutor$runAsyncActionWithTimeout$3.run(RenderExecutor.kt:204)
at com.android.tools.rendering.RenderExecutor$PriorityRunnable.run(RenderExecutor.kt:321)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.base/java.lang.Thread.run(Unknown Source)
cm...@google.com <cm...@google.com> #19
Great to see this is fixed, which Android Studio release will have the fix included? Will the fix make its way into 2024.2.2?
za...@gmail.com <za...@gmail.com> #20
No, unfortunately the fix will not be available for 2024.2.2. The next Meerkat Canary will have the fix. It should also be available in the Nightly build already.
cm...@google.com <cm...@google.com> #21
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 | 2024.3.1 Canary 3
- Android Gradle Plugin 8.9.0-alpha03
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!
jo...@monzo.com <jo...@monzo.com> #22
I noticed this still triggers even when explicitly using the DefaultLocale
e.g. val test = "Hello World".decapitalize(Locale.getDefault())
. I've attached a sample project to reproduce this.
Kotlin version: 1.4.0
Build tools: 4.1.0-rc01
cm...@google.com <cm...@google.com> #23
cm...@google.com <cm...@google.com> #24
Matthew, what do you think?
gh...@google.com <gh...@google.com> #25
The issues will be fixed "properly" in 4.2 Canary 11, which bundles Kotlin compiler 1.4 and can resolve the new decapitalize method.
By the way, since Lint in AGP 4.1 bundles Kotlin compiler 1.3, I suspect there are other issues besides just this one. For example, Lint may fail to parse sources that use Kotlin 1.4 language features.
I wish Lint could run with the exact Kotlin compiler that is used to compile the project, but that is not how things work currently. And it may not be possible because the Kotlin compiler does not have a stable API. So in general it takes some time for Lint to integrate new Kotlin language versions.
Description
It wants to use the overload with a Locale but there isn't one defined in Kotlin as of Version 1.3.31. I think there is one starting with Kotlin 1.3.40 but that one hasn't been released yet.
The same happens for `capitalize()`