转到你的gradle.properties文件检查你里面有这个或添加它:
android.enableJetifier=true
android.useAndroidX=true
然后转到您的build.gradle (app) 并将其添加到 android{
dataBinding {
enabled = true
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = JavaVersion.VERSION_1_8
}
这里没有更新udacity课程是我使用的依赖版本
注意这部分:
不要将其用作 Udacity 建议(在 build.gradle 应用程序级别)
不要使用 android.arch
// Navigation
implementation "android.arch.navigation:navigation-fragment-ktx:$version_navigation"
implementation "android.arch.navigation:navigation-ui-ktx:$version_navigation"
利用
// Navigation
implementation "androidx.navigation:navigation-fragment-ktx:2.3.0-alpha04"
implementation "androidx.navigation:navigation-ui-ktx:2.3.0-alpha04"
并在 build.gradle (项目级别)
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:2.3.0-alpha04
这是使用版本的完整依赖项列表(以防万一)
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
apply plugin: 'androidx.navigation.safeargs'
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.21"
// Support libraries
implementation "androidx.constraintlayout:constraintlayout:1.1.3"
// Android KTX
implementation "androidx.core:core-ktx:"1.2.0"
// Room and Lifecycle dependencies
implementation "androidx.room:room-runtime:$version_room"
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
kapt "androidx.room:room-compiler:"2.0.0"
implementation "androidx.lifecycle:lifecycle-extensions:2.2.0"
// Coroutines
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:"1.1.0"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:"1.1.0"
// Navigation
implementation "androidx.navigation:navigation-fragment-ktx:2.3.0-alpha04"
implementation "androidx.navigation:navigation-ui-ktx:2.3.0-alpha04"
// Testing
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
}