Home > Software engineering >  Divider component not found in Android Jetpack Compose project
Divider component not found in Android Jetpack Compose project

Time:10-27

I'm currently working on an Android UI entirely Compose based. I need to put a Divider component between 2 lists implemented as LazyColumn (vertical) and LazyRow (horizontal).

When I try to use the component, IntelliJ cannot suggest any dependency reference for Divider:

enter image description here

I already use the "androidx.compose.material" for other components in the UI and these are correctly imported:

enter image description here

I even tried to add the reference manually using the import but nothing is found:

enter image description here

Just for completeness, this are all the gradle app dependencies I actually use in the project:

`

implementation 'androidx.core:core-ktx:1.7.0'
implementation "androidx.compose.ui:ui:$compose_version"
implementation 'androidx.compose.material3:material3:1.0.0-alpha01'
implementation "androidx.compose.ui:ui-tooling-preview:$compose_version"
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.3.1'
implementation 'androidx.activity:activity-compose:1.3.1'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_version"
debugImplementation "androidx.compose.ui:ui-tooling:$compose_version"
debugImplementation "androidx.compose.ui:ui-test-manifest:$compose_version"

`

Any suggestion how to solve ?

CodePudding user response:

You are missing a dependency

implementation "androidx.compose.material:material:$compose_version"

CodePudding user response:

In your dependencies you are using M3:

implementation 'androidx.compose.material3:material3:1.0.0-alpha01'

In this case to use the Divider composable you have to import the right package:

import androidx.compose.material3.Divider

and pls note you cloud switch to stable 1.0.0 or 1.1.0-alpha01.
If you want to use M2 (androidx.compose.material.Divider) you have to add the dependency

implementation("androidx.compose.material:material:1.3.0")
  • Related