问题描述
它显示: 无法解决: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 repository
和google()
,请在应用目录之外的build.gradle
内执行此操作。
allprojects {
repositories {
google()
maven {
url 'https://maven.google.com'
}
jcenter()
}
}
,
v30支持库不存在。
删除它们。
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()
}
}