android - 错误 : Failed to resolve: androidx. 旧版:legacy-support-v4

标签 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

最佳答案

使用

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

代替

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

关于android - 错误 : Failed to resolve: androidx. 旧版:legacy-support-v4,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57778013/

相关文章:

java - 如何从实时数据中删除观察者,以便在导航回 fragment 时不会显示两次

java - android中的空指针异常错误

android - 在库中添加 Gradle 构建文件夹

android - AndroidX 中的 BottomSheetBehavior

android - 用于构建 XML 服务器以在 Android 应用程序上显示的服务模块

android - 自定义方形线性布局。如何?

android - 更新到 com.android.tools.build :gradle:7. 1.0 后,Gradle 构建在 "lint isAbortOnError"失败

java - 如何使用 Gradle 抑制 "warning: Ignoring InnerClasses attribute for an anonymous inner class"?

java - 二进制 XML 文件行 #10 : Error inflating class com. google.android.material.button.API 级别 19 的 MaterialButton

java - 迁移到 Androidx 后无法解析方法 setAdapter