Android Studio Bumblebee 中的新 build.gradle | 2021.1.1 Beta 5 添加依赖项时出错

Abd*_*lan 5 gradle build.gradle android-architecture-navigation

我更新了 Android Studio,现在在顶级 build.gradle 中没有依赖项范围,而是有插件范围。我想添加导航安全参数的依赖项。在旧版本中,我可以添加如下内容:

dependencies {
    def nav_version = "2.3.5"
    classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$nav_version"
}
Run Code Online (Sandbox Code Playgroud)

但现在我们有了插件范围。

plugins {
id 'com.android.application' version '7.2.0-alpha02' apply false
id 'com.android.library' version '7.2.0-alpha02' apply false
id 'org.jetbrains.kotlin.android' version '1.5.31' apply false }
Run Code Online (Sandbox Code Playgroud)

我向此范围添加了 safe-args 插件

id "androidx.navigation:navigation-safe-args-gradle-plugin" version "2.3.5" apply false
Run Code Online (Sandbox Code Playgroud)

,但我收到此错误:
插件 id 'androidx.navigation:navigation-safe-args-gradle-plugin' 无效:插件 id 包含无效的字符 ':'

Naf*_*bbo 9

你可以做这件事。

ext {
    compose_version = '1.0.5'
    kotlin_version = '1.6.10'
}
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
    id 'com.android.application' version '7.1.0' apply false
    id 'com.android.library' version '7.1.0' apply false
    id 'org.jetbrains.kotlin.android' version "$kotlin_version" apply false
    id "com.google.dagger.hilt.android" version "2.41" apply false
    id 'androidx.navigation.safeargs.kotlin' version '2.5.0-alpha01' apply false // use this one
//    classpath "androidx.navigation:navigation-safe-args-gradle-plugin:2.4.0" (will not work now)

}

task clean(type: Delete) {
    delete rootProject.buildDir
}
Run Code Online (Sandbox Code Playgroud)

  • `2.4.0` 给我错误,`2.5.0-alpha01` 对我有用:/sf/answers/4960023421/ (2认同)