• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Android Studio Preview Rendering problems

Donce2023

Lurker
Hi, I am trying to learn Android development. I am learning from developer.android.com/courses

And have problems with @Preview rendering.

Every time I change something in code (even if I just added new line) preview try to automatically Build and Refresh, but every time it fails. It says "Some issues were found while trying to render this preview".
In Problems window I see some Render problems in Compose tab.

Rich (BB code):
android.content.res.Resources$NotFoundException: Could not resolve resource value: 0x1CFDEB.   at android.content.res.Resources_Delegate.throwException(Resources_Delegate.java:1161)   at android.content.res.Resources_Delegate.throwException(Resources_Delegate.java:1137)   at android.content.res.Resources_Delegate.throwException(Resources_Delegate.java:1141)   at android.content.res.Resources_Delegate.getString(Resources_Delegate.java:823)   at android.content.res.Resources.getString(Resources.java:546)   at androidx.compose.ui.res.StringResources_androidKt.stringResource(StringResources.android.kt:39)   at com.example.superheroes.HeroesScreenKt.HeroItem(HeroesScreen.kt:30)   at com.example.superheroes.HeroesScreenKt$HeroPreview$1.invoke(HeroesScreen.kt:49)   at com.example.superheroes.HeroesScreenKt$HeroPreview$1.invoke(HeroesScreen.kt:48)   at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:107)   at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34)   at androidx.compose.material.MaterialTheme_androidKt.PlatformMaterialTheme(MaterialTheme.android.kt:23)   at androidx.compose.material.MaterialThemeKt$MaterialTheme$1$1.invoke(MaterialTheme.kt:82)   at androidx.compose.material.MaterialThemeKt$MaterialTheme$1$1.invoke(MaterialTheme.kt:81)   at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:107)   at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34)   at androidx.compose.runtime.CompositionLocalKt.CompositionLocalProvider(CompositionLocal.kt:228)   at androidx.compose.material.TextKt.ProvideTextStyle(Text.kt:265)   at androidx.compose.material.MaterialThemeKt$MaterialTheme$1.invoke(MaterialTheme.kt:81)   at androidx.compose.material.MaterialThemeKt$MaterialTheme$1.invoke(MaterialTheme.kt:80)   at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:107)   at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34)   at androidx.compose.runtime.CompositionLocalKt.CompositionLocalProvider(CompositionLocal.kt:228)   at androidx.compose.material.MaterialThemeKt.MaterialTheme(MaterialTheme.kt:72)   at com.example.superheroes.ui.theme.ThemeKt.SuperheroesTheme(Theme.kt:38)   at com.example.superheroes.HeroesScreenKt.HeroPreview(HeroesScreen.kt:48)   at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(NativeMethodAccessorImpl.java:-2)   at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)   at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)   at java.lang.reflect.Method.invoke(Method.java:566)   at androidx.compose.ui.tooling.ComposableInvoker.invokeComposableMethod(ComposableInvoker.kt:155)   at androidx.compose.ui.tooling.ComposableInvoker.invokeComposable(ComposableInvoker.kt:195)   at androidx.compose.ui.tooling.ComposeViewAdapter$init$3$1$composable$1.invoke(ComposeViewAdapter.kt:590)   at androidx.compose.ui.tooling.ComposeViewAdapter$init$3$1$composable$1.invoke(ComposeViewAdapter.kt:588)   at androidx.compose.ui.tooling.ComposeViewAdapter$init$3$1.invoke(ComposeViewAdapter.kt:625)   at androidx.compose.ui.tooling.ComposeViewAdapter$init$3$1.invoke(ComposeViewAdapter.kt:583)   at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:107)   at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34)   at androidx.compose.runtime.CompositionLocalKt.CompositionLocalProvider(CompositionLocal.kt:228)   at androidx.compose.ui.tooling.InspectableKt.Inspectable(Inspectable.kt:61)   at androidx.compose.ui.tooling.ComposeViewAdapter$WrapPreview$1.invoke(ComposeViewAdapter.kt:531)   at androidx.compose.ui.tooling.ComposeViewAdapter$WrapPreview$1.invoke(ComposeViewAdapter.kt:530)   at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:107)   at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34)   at androidx.compose.runtime.CompositionLocalKt.CompositionLocalProvider(CompositionLocal.kt:228)   at androidx.compose.ui.tooling.ComposeViewAdapter.WrapPreview(ComposeViewAdapter.kt:525)   at androidx.compose.ui.tooling.ComposeViewAdapter.access$WrapPreview(ComposeViewAdapter.kt:124)   at androidx.compose.ui.tooling.ComposeViewAdapter$init$3.invoke(ComposeViewAdapter.kt:583)   at androidx.compose.ui.tooling.ComposeViewAdapter$init$3.invoke(ComposeViewAdapter.kt:580)   at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:107)   at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34)   at androidx.compose.ui.platform.ComposeView.Content(ComposeView.android.kt:402)   at androidx.compose.ui.platform.AbstractComposeView$ensureCompositionCreated$1.invoke(ComposeView.android.kt:248)   at androidx.compose.ui.platform.AbstractComposeView$ensureCompositionCreated$1.invoke(ComposeView.android.kt:247)   at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:107)   at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34)   at androidx.compose.runtime.CompositionLocalKt.CompositionLocalProvider(CompositionLocal.kt:228)   at androidx.compose.ui.platform.CompositionLocalsKt.ProvideCommonCompositionLocals(CompositionLocals.kt:177)   at androidx.compose.ui.platform.AndroidCompositionLocals_androidKt$ProvideAndroidCompositionLocals$3.invoke(AndroidCompositionLocals.android.kt:123)   at androidx.compose.ui.platform.AndroidCompositionLocals_androidKt$ProvideAndroidCompositionLocals$3.invoke(AndroidCompositionLocals.android.kt:122)   at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:107)   at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34)   at androidx.compose.runtime.CompositionLocalKt.CompositionLocalProvider(CompositionLocal.kt:228)   at androidx.compose.ui.platform.AndroidCompositionLocals_androidKt.ProvideAndroidCompositionLocals(AndroidCompositionLocals.android.kt:114)   at androidx.compose.ui.platform.WrappedComposition$setContent$1$1$3.invoke(Wrapper.android.kt:157)   at androidx.compose.ui.platform.WrappedComposition$setContent$1$1$3.invoke(Wrapper.android.kt:156)   at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:107)   at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34)   at androidx.compose.runtime.CompositionLocalKt.CompositionLocalProvider(CompositionLocal.kt:228)   at androidx.compose.ui.platform.WrappedComposition$setContent$1$1.invoke(Wrapper.android.kt:156)   at androidx.compose.ui.platform.WrappedComposition$setContent$1$1.invoke(Wrapper.android.kt:140)   at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:107)   at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34)   at androidx.compose.runtime.ActualJvm_jvmKt.invokeComposable(ActualJvm.jvm.kt:74)   at androidx.compose.runtime.ComposerImpl$doCompose$2$5.invoke(Composer.kt:3193)   at androidx.compose.runtime.ComposerImpl$doCompose$2$5.invoke(Composer.kt:3183)   at androidx.compose.runtime.SnapshotStateKt__DerivedStateKt.observeDerivedStateRecalculations(DerivedState.kt:252)   at androidx.compose.runtime.SnapshotStateKt.observeDerivedStateRecalculations  at androidx.compose.runtime.ComposerImpl.doCompose(Composer.kt:3183)   at androidx.compose.runtime.ComposerImpl.composeContent$runtime_release(Composer.kt:3119)   at androidx.compose.runtime.CompositionImpl.composeContent(Composition.kt:584)   at androidx.compose.runtime.Recomposer.composeInitial$runtime_release(Recomposer.kt:811)   at androidx.compose.runtime.CompositionImpl.setContent(Composition.kt:519)   at androidx.compose.ui.platform.WrappedComposition$setContent$1.invoke(Wrapper.android.kt:140)   at androidx.compose.ui.platform.WrappedComposition$setContent$1.invoke(Wrapper.android.kt:131)   at androidx.compose.ui.platform.AndroidComposeView.setOnViewTreeOwnersAvailable(AndroidComposeView.android.kt:1015)   at androidx.compose.ui.platform.WrappedComposition.setContent(Wrapper.android.kt:131)   at androidx.compose.ui.platform.WrappedComposition.onStateChanged(Wrapper.android.kt:182)   at androidx.lifecycle.LifecycleRegistry$ObserverWithState.dispatchEvent(LifecycleRegistry.java:354)   at androidx.lifecycle.LifecycleRegistry.addObserver(LifecycleRegistry.java:196)   at androidx.compose.ui.platform.WrappedComposition$setContent$1.invoke(Wrapper.android.kt:138)   at androidx.compose.ui.platform.WrappedComposition$setContent$1.invoke(Wrapper.android.kt:131)   at androidx.compose.ui.platform.AndroidComposeView.onAttachedToWindow(AndroidComposeView.android.kt:1102)   at android.view.View.dispatchAttachedToWindow(View.java:21291)   at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3491)   at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3498)   at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3498)   at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3498)   at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3498)   at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3498)   at android.view.AttachInfo_Accessor.setAttachInfo(AttachInfo_Accessor.java:58) Copy stack to clipboard   Tip: Try to refresh the layout.

But if I manually Build and Refresh no problems are found and everything works. This is very frustrating.

For new assignment I had to create HeroesScreen.kt file and write some code here. I tried to create @Preview in HeroesScreen.kt but was not even able to move from "Code" tab to "Split" tab. Pressing on Split tab did not do anything. Closed Android Studio and opened it again and was able to press and open Split window. But preview would show same issues as above, even if I Build and Refresh manually.
Opened MainActivity.kt file to write some code here. Wanted to copy code from HeroesScreen.kt so I opened it and @Preview is rendered no issues.

I made screen video
 
Back
Top Bottom