資訊一覽設定

本頁面說明如何設定開發環境以使用 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

設定下列選項,確保 Glance 可使用 Compose 編譯器


android {
   buildFeatures {
      compose true
   }

   composeOptions {
      kotlinCompilerExtensionVersion = "1.5.11"
   }

   kotlinOptions {
      jvmTarget = "1.8"
   }
}


您可以在 Glance 版本頁面中找到可用的最新版本。