错误:无法解决:androidx.legacy:legacy-support-v4

时间:2019-09-03 19:57:59

标签: android android-gradle-plugin androidx

迁移到androidx后,此错误一直显示,有人可以帮助我吗?

这是build.gradle的一部分


buildscript {
    repositories {
        google()
        maven {
            url 'https://maven.google.com'
        }
        jcenter()


    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.4.2'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        maven {
            url 'https://maven.google.com'
        }
        jcenter()

    }
}

这是build.gradle(app)中的依赖项列表

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'androidx.appcompat:appcompat:1.0.2'
    implementation 'com.google.android.gms:play-services-maps:17.0.0'
    implementation 'androidx.legacy:legacy-support-v4'
    //implementation 'androidx.legacy:legacy-support-v13'
    testImplementation 'junit:junit:4.12'

    androidTestImplementation 'androidx.test:runner:1.3.0-alpha02'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0-alpha02'
}

这是我尝试同步项目时的单行错误

ERROR: Failed to resolve: androidx.legacy:legacy-support-v4:
Affected Modules: app

1 个答案:

答案 0 :(得分:1)

使用

implementation 'androidx.legacy:legacy-support-v4:1.0.0'

代替

implementation 'androidx.legacy:legacy-support-v4'