Kotlin与Jetpack Compose中ExpandLess/ExpandMore引用未解决求助
解决Jetpack Compose中“Unresolved reference: ExpandLess/ExpandMore”错误
检查Material图标依赖
ExpandLess和ExpandMore属于Jetpack Compose的Material扩展图标库,需在模块级build.gradle.kts(或build.gradle)中添加对应依赖:// build.gradle.kts(Kotlin DSL)示例 dependencies { implementation("androidx.compose.material:material-icons-extended:1.5.4") // 确保该版本与你项目中其他Compose依赖(如material、ui等)版本一致 }替换
1.5.4为你项目实际使用的Compose版本号,避免版本冲突导致依赖加载异常。添加正确的导入语句
在使用图标的Compose函数文件顶部,导入对应图标类:import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.ExpandLess import androidx.compose.material.icons.filled.ExpandMore若教程中使用的是其他风格图标(如Outlined、Rounded),需将
filled替换为对应风格的包名。同步并重建项目
添加依赖和导入后,点击Android Studio右上角的「Sync Project with Gradle Files」同步项目,再执行Build > Clean Project和Build > Rebuild Project,确保依赖完全加载。
内容的提问来源于stack exchange,提问作者LetsWalle
相关产品推荐
相关产品推荐

