Glance 设置

本页介绍了如何设置开发环境以使用 Glance。

根据要构建的“Glanceable”类型,在应用模块中添加特定的 Glance 依赖项。

dependencies {
   // For AppWidgets support
   implementation "androidx.glance:glance-appwidget:1.1.0"

   // For interop APIs with Material 3
   implementation "androidx.glance:glance-material3:1.1.0"

   // For interop APIs with Material 2
   implementation "androidx.glance:glance-material:1.1.0"
}

激活 Compose Compiler

设置以下选项,以确保 Compose 编译器可用于 Glance


android {
   buildFeatures {
      compose true
   }

   composeOptions {
      kotlinCompilerExtensionVersion = "1.5.13"
   }

   kotlinOptions {
      jvmTarget = "1.8"
   }
}

您可以从 Glance 发布页面获取最新的可用版本。