我將使用帶有片段的導航框架,但在依賴步驟中,當我嘗試從檔案中添加 SafeArgs 時,我發現新的頂級 gradle 檔案與檔案不同,因此我無法添加它。你能解釋一下如何將 SafeArgs 添加到新的 kotlin 頂級 gradle 檔案中嗎?
我的頂級 gradle 檔案:
plugins {
id 'com.android.application' version '7.1.2' apply false
id 'com.android.library' version '7.1.2' apply false
id 'org.jetbrains.kotlin.android' version '1.6.10' apply false}
task clean(type: Delete) {
delete rootProject.buildDir}
檔案頂級 Gradle:
buildscript {
repositories {
google()
}
dependencies {
val nav_version = "2.4.1"
classpath("androidx.navigation:navigation-safe-args-gradle-plugin:$nav_version")
}}
提前致謝。
uj5u.com熱心網友回復:
您的頂級(專案級別)Gradle 檔案位于 Groovy 中,而檔案位于 KotlinScript 中。您需要將檔案代碼復制并粘貼到頂級 Gradle 檔案中,并進行一些更改,如下所示:
buildscript {
repositories {
google()
}
dependencies {
nav_version = "2.4.1"
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$nav_version"
}
}
此外,請考慮將plugins定義移動到您的應用級 Gradle 檔案。
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/438985.html
