Status Update
Comments
ub...@gmail.com <ub...@gmail.com> #2
vi...@google.com <vi...@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.
ub...@gmail.com <ub...@gmail.com> #4
I do not see this issue in Electric Eel Beta 4, but I do see it in Flamingo Canary 6.
ub...@gmail.com <ub...@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!
vi...@google.com <vi...@google.com>
se...@google.com <se...@google.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.
da...@google.com <da...@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
cs...@google.com <cs...@google.com> #8
ad...@google.com <ad...@google.com> #9
da...@google.com <da...@google.com> #10
Diego, this looks to be the same problem as
cs...@google.com <cs...@google.com> #11
This looks to be the same as
da...@google.com <da...@google.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
cs...@google.com <cs...@google.com> #13
The fix for this will be in a future canary of Flamingo.
pe...@google.com <pe...@google.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.
ub...@gmail.com <ub...@gmail.com> #15
I noticed this as well, and created this issue
cs...@google.com <cs...@google.com> #16
aa...@google.com <aa...@google.com> #17
Reopening as this doesn't seem to be fixed, according to multiple reports.
ub...@gmail.com <ub...@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)
aa...@google.com <aa...@google.com>
an...@google.com <an...@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?
Description
Build: AI-193.6911.18.41.6362631, 202004031740,
AI-193.6911.18.41.6362631, JRE 1.8.0_242-release-1644-b3-6222593x64 JetBrains s.r.o, OS Mac OS X(x86_64) v10.15.4, screens 1440x900; Retina
AS: 4.1 Canary 5; Kotlin plugin: 1.3.71-release-Studio4.0-1; Android Gradle Plugin: 4.1.0-alpha05; Gradle: 6.3; NDK: from local.properties: (not specified), latest from SDK: (not found); LLDB: pinned revision 3.1 not found, latest from SDK: (package not found); CMake: from local.properties: (not specified), latest from SDK: (not found), from PATH: (not found)