Glance 设置
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
本页面介绍了如何设置开发环境以使用 Glance。您可以从发布页面获取最新的可用版本。
根据您要构建的“一览式”应用的类型,在应用模块中添加特定的 Glance 依赖项。
dependencies {
// For AppWidgets support
implementation "androidx.glance:glance-appwidget:1.1.1"
// For interop APIs with Material 3
implementation "androidx.glance:glance-material3:1.1.1"
// For interop APIs with Material 2
implementation "androidx.glance:glance-material:1.1.1"
}
激活 Compose 编译器
设置以下选项,以确保 Compose 编译器可用于 Glance:
android {
buildFeatures {
compose true
}
composeOptions {
kotlinCompilerExtensionVersion = "1.5.15"
}
kotlinOptions {
jvmTarget = "1.8"
}
}
本页面上的内容和代码示例受内容许可部分所述许可的限制。Java 和 OpenJDK 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-08-21。
[null,null,["最后更新时间 (UTC):2025-08-21。"],[],[],null,["# Glance setup\n\nThis page describes how to set up your development environment to use Glance.\nYou can get the latest available version from\n[the release page](/jetpack/androidx/releases/glance).\n\nAdd the specific Glance dependency in your app's module based on the type of\n\"glanceable\" you want to build. \n\n dependencies {\n // For AppWidgets support\n implementation \"androidx.glance:glance-appwidget:1.1.1\"\n\n // For interop APIs with Material 3\n implementation \"androidx.glance:glance-material3:1.1.1\"\n\n // For interop APIs with Material 2\n implementation \"androidx.glance:glance-material:1.1.1\"\n }\n\nActivate Compose compiler\n-------------------------\n\nSet the following options to ensure that the Compose compiler is available for\nGlance: \n\n\n android {\n buildFeatures {\n compose true\n }\n\n composeOptions {\n kotlinCompilerExtensionVersion = \"1.5.15\"\n }\n\n kotlinOptions {\n jvmTarget = \"1.8\"\n }\n }"]]