Taslim Oseni
Taslim Oseni

Reputation: 6273

Jetpack Compose: Stack cannot be resolved

I am new to Jetpack compose and I'm currently trying to implement a Stack (composable). For some reason, I can't get a reference to it. I have tried adding it to my imports as shown below, but the Stack part is not getting resolved.

 import androidx.compose.foundation.layout.Stack

Autocomplete can't seem to get it either as shown below:

Trying to reference JetPack Compose Stack

I included org.jetbrains.kotlin.android among the list of my plugins. Highlighted below is a list of my dependencies:

    implementation 'androidx.core:core-ktx:1.5.0'
    implementation 'androidx.appcompat:appcompat:1.3.0'
    implementation 'com.google.android.material:material:1.3.0'
    implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.3.1'
    implementation 'androidx.activity:activity-compose:1.3.0-alpha02'
    implementation("androidx.compose.ui:ui:1.0.0-beta07")
    implementation("androidx.compose.ui:ui-tooling:1.0.0-beta07")
    implementation("androidx.compose.foundation:foundation:1.0.0-beta07")
    implementation("androidx.compose.material:material:1.0.0-beta07")
    implementation("androidx.compose.material:material-icons-core:1.0.0-beta07")
    implementation("androidx.compose.material:material-icons-extended:1.0.0-beta07")
    implementation("androidx.compose.runtime:runtime-livedata:1.0.0-beta07")
    implementation("androidx.compose.runtime:runtime-rxjava2:1.0.0-beta07")
    androidTestImplementation("androidx.compose.ui:ui-test-junit4:1.0.0-beta07")

How do I fix this?

Upvotes: 3

Views: 3014

Answers (1)

Code Poet
Code Poet

Reputation: 8033

Stack is deprecated. Use Box() instead.

Since Version 1.0.0-alpha04: "Stack was renamed to Box. The previously existing Box will be deprecated in favor of the new Box in compose.foundation.layout. The behavior of the new Box is to stack children one on top of another when it has multiple children - this is different from the previous Box, which was behaving similar to a Column. (I94893, b/167680279)"

https://developer.android.com/jetpack/androidx/releases/compose-ui?authuser=1#1.0.0-alpha04

Upvotes: 16

Related Questions