无法解决:com.android.support:support-v4:30.0.0

问题描述

显示 无法解决:com.android.support:support-v4:30.0.0 添加Google Maven存储库并同步项目 在项目结构对话框中显示 受影响的模块:应用

build.gradle(:app):

应用插件:“ com.android.application”

android { 编译版本30 buildToolsversion '30 .0.2'

defaultConfig {
    applicationId "com.example.android.miwok"
    minSdkVersion 15
    targetSdkVersion 30
    versionCode 1
    versionName "1.0"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'),'proguard-rules.pro'
    }
}

}

dependencies {
    implementation filetree(dir: 'libs',include: ['*.jar'])
    testImplementation 'junit:junit:4.12'
    implementation 'com.android.support:appcompat-v7:30.0.0'
    implementation 'com.android.support:support-v4:30.0.0'
    implementation 'com.android.support:design:30.0.0'
}

解决方法

主要使用androidx库,您现在需要使用它:

要使用此功能,如果您的项目没有迁移到Androidx,则需要为其添加Androidx支持。

您可以在此处找到如何将项目迁移到Androidx

implementation 'androidx.appcompat:appcompat:1.2.0'

或使用最后一个support library

implementation 'com.android.support:appcompat-v7:28.0.0'

这是因为您尝试使用的support libraries不存在。

对于添加Google Maven repositorygoogle(),请在应用目录之外的build.gradle内执行此操作。

allprojects {
    repositories {

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

v30支持库不存在
删除它们。

使用androidx libraries

    implementation 'androidx.appcompat:appcompat:1.2.0'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'com.google.android.material:material:1.2.1'

要使用它们,您必须在顶级google()文件中添加build.gradle仓库:

allprojects {
    repositories {
        google()
        jcenter()
    }
}

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...