如要設定 NavigationEvent 的開發環境,請按照下列步驟操作。
宣告依附元件
在專案中加入
navigationevent構件。這是包含共用NavigationEventDispatcher和NavigationEventHandler類別的核心程式庫。如要整合 Jetpack Compose,您也需要新增對應的 Compose 構件:
[versions] navigationevent = "1.0.0" [libraries] # NavigationEvent libraries androidx-navigationevent = { module = "androidx.navigationevent:navigationevent", version.ref = "navigationevent" } androidx-navigationevent-compose = { module = "androidx.navigationevent:navigationevent-compose", version.ref = "navigationevent" }將編譯 SDK 更新至 36 以上版本:
[versions] compileSdk = "36"在應用程式建構檔案
app/build.gradle.kts中新增下列內容:dependencies { ... implementation(libs.androidx.navigationevent) implementation(libs.androidx.navigationevent.compose) }