无法解析':app @ debugUnitTest / compileClasspath'的依赖项:无法解析androidx.legacy:legacy-support-v4:1.0.0

时间:2020-09-19 14:13:00

标签: android android-studio android-fragments

当我添加新的Fragment(blank)时,在Gradle同步中出现未解决的错误。即使在新项目中也会发生。我的android studio是v4.0.1。我最近更新了。

这是我的Gradle代码。

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

android {
compileSdkVersion 30
buildToolsVersion "30.0.2"

defaultConfig {
    applicationId "com.example.navigationdemo"
    minSdkVersion 26
    targetSdkVersion 30
    versionCode 1
    versionName "1.0"

    testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
    }
  }
}

dependencies {
 implementation fileTree(dir: "libs", include: ["*.jar"])
 implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
 implementation 'androidx.core:core-ktx:1.3.1'
 implementation 'androidx.appcompat:appcompat:1.2.0'
 implementation 'androidx.constraintlayout:constraintlayout:2.0.1'
 implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
 implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0'
 implementation 'androidx.legacy:legacy-support-v4:1.0.0'
 testImplementation 'junit:junit:4.13'
 androidTestImplementation 'androidx.test.ext:junit:1.1.2'
 androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'

 // navigation component
 implementation 'androidx.navigation:navigation-fragment-ktx:2.3.0'
 implementation 'androidx.navigation:navigation-ui-ktx:2.3.0'
}

这是发生Could not resolve androidx.legacy:legacy-support-v4:1.0.0

的错误

1 个答案:

答案 0 :(得分:0)

当我在依赖项行中评论我的应用程序工作时。我发现这说明了旧的依赖关系 What is the use of androidx.legacy:legacy-support-v4: dependencie