Andranik
Andranik

Reputation: 2849

Jetpack Compose fails preview if there is a Text composable in composition

My Android Studio version is Android Studio Electric Eel | 2022.1.1 Patch 1 My jetpack compose related dependencies are as follows:

    implementation platform('androidx.compose:compose-bom:2023.01.00')
    implementation "androidx.compose.foundation:foundation"
    implementation "androidx.compose.ui:ui"
    debugImplementation 'androidx.compose.ui:ui-tooling'
    implementation "androidx.compose.ui:ui-tooling-preview"
    implementation "androidx.compose.material3:material3:1.1.0-beta02"
    implementation "androidx.compose.material3:material3-window-size-class"

Everything works fine, but when I include even a single Text composable in the composition the Preview brakes with message some issues were found when trying to render this preview So this preview does not work:

@Preview(showSystemUi = true, showBackground = true)
@Composable
fun PreviewTest() {
    Text(text = "hello")
}

but putting anything else instead of Text works just fine. Any ideas why this can happen?

Upvotes: 3

Views: 1724

Answers (2)

maru
maru

Reputation: 41

I think it will be easier to find the cause if you share the problem window of android studio.

enter image description here

Upvotes: 1

Shift Delete
Shift Delete

Reputation: 1054

Upgrade Android Studio to Flamingo. It seems Electric Eel and Dolphin have some preview-related issues.

Upvotes: 3

Related Questions