本页介绍如何设置开发环境以使用 Glance。
添加 Glance 依赖项
根据您需要的功能,在应用的模块中添加特定的 Glance 依赖项:
dependencies {
// For AppWidgets support
implementation( "androidx.glance:glance-appwidget:1.0.0" )
// For interop APIs with Material 2
implementation( "androidx.glance:glance-material:1.0.0" )
// For interop APIs with Material 3
implementation( "androidx.glance:glance-material3:1.0.0" )
}
激活 Compose Compiler
请设置以下选项,以确保 Compose 编译器可用于 Glance
android {
buildFeatures {
compose true
}
composeOptions {
kotlinCompilerExtensionVersion = "1.5.11"
}
kotlinOptions {
jvmTarget = "1.8"
}
}
您可以从 Glance 版本页面获取最新的可用版本。