【发布时间】:2020-02-16 17:06:31
【问题描述】:
我试图添加导航依赖项以在我的项目中使用导航图,而 android studio 抛出了这个错误。
这是我的项目 Gradle 文件:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.3.50'
repositories {
google()
jcenter()
nav_version = "2.3.0-alpha01" //extra property, used like variables
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$nav_version"
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
如您所见,我添加了 $nav_version 依赖项和 nav_version 变量。但是,android studio 会抛出“无法为 org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler 类型的对象设置未知属性 'nav_version'”错误。我想知道它是否与 Gradle 版本或我的 Kotlin 版本有关。我试图清理并重新构建我的项目,但没有奏效。我想知道是否有人遇到过类似的事情。
【问题讨论】:
标签: java android gradle kotlin navigation