Glance 设置

本页面介绍如何设置您的开发环境以使用 Glance。您可以从发布页面获取最新可用版本。

根据您要构建的“glanceable”类型,在应用模块中添加特定的 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"
   }
}