本頁面說明如何設定使用 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.14"
}
kotlinOptions {
jvmTarget = "1.8"
}
}
您可以前往資訊一覽頁面取得最新版本。