无法解析:com.android.support:appcompat-v7:28.+ ,错误:多个具有包名称的库'android.support.graphics.drawable'



我是安卓工作室的新手,我想尽一切办法来解决这个问题"未能解决:com.Android.support:appcompat-v7:28.+">

我试图清理项目,使现金无效/重新启动并删除。想法仍然是

我使用android studio 2.2.1是出于学习的原因,我将其更新到了android studio 3,出现了多个渲染问题,所以我回到了2.2.1版本

我试着添加

maven{
url'https://maven.google.com/'名称"谷歌"}

所以,它遇到了另一个问题

"Error:Execution failed for task ':app:processDebugResources'.
> Error: more than one library with package name 'android.support.graphics.drawable'"

错误照片

最后,我尝试将"appcompat-v7:28.+"更改为"appcompant-v7:27",它仍然有效,但仍然告诉我应该使用相同的库来避免错误

这是我的Gradle代码:

apply plugin: 'com.android.application'
android {
compileSdkVersion 28
buildToolsVersion "28.0.1"
defaultConfig {
applicationId "com.example.aimlive.myapplication"
minSdkVersion 15
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:28.+'
testCompile 'junit:junit:4.12'
}

'com.android.support:appcompat-v7:28.0.0'替换'com.android.support:appcompat-v7:28+'

并添加以下依赖项

implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.android.support:support-media-compat:28.0.0'
implementation 'com.android.support:animated-vector-drawable:28.0.0'
implementation 'com.android.support:customtabs:28.0.0'

尝试将其添加到代码中:

repositories {
jcenter()
maven {                                  // <-- Add this
url 'https://maven.google.com/'
}
}

更新:现在您转到另一个错误:

错误:多个库的包名为android.support.graphics.drawable…

要解决此问题,需要在dependencies部分中将compile更改为implementation

如果您正在使用

compileSdkVersion 28

在代码下面添加您的依赖项

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

这是链接

试试这个,希望它能在中工作

implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'

依赖

classpath 'com.android.tools.build:gradle:3.1.4'

安卓

compileSdkVersion 28
minSdkVersion 21
targetSdkVersion 28

试试这段代码,希望它能正常工作。感谢

build.gradle(项目(

dependencies {
classpath 'com.android.tools.build:gradle:3.1.4'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}

build.gradle(应用程序(

android {
compileSdkVersion 28
buildToolsVersion '28.0.3'
defaultConfig {
applicationId "YOUR_PACKAGE_NAME"
minSdkVersion 15
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
renderscriptTargetApi 19
renderscriptSupportModeEnabled true
// Enabling multidex support.
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
lintOptions {
abortOnError false
}

}

实现的依赖性检查

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')

}

我发现"com.android.support:animated vector drawable"one_answers"com.andrio.support:support vector drawable"在28.0.0版本的支持库中具有相同的包名。通常情况下,这不会造成问题。

但如果你在grade.properties 中有以下行

android.uniquePackageNames = true

你会看到错误

more than one library with package name 'android.support.graphics.drawable'"

如果您应该使用uniquePackageNames选项,请使用androidx而不是支持库28.0.0。

In case someone like me stuck for hours and find out the you have to check the maven dependency "com.android.support:appcompat-v7:28.0.0". remove the "+" sign as gradle does not like it for unpredictable versions. so i had to check the maven repository and found that i was compiling with 29 and 29 does not exist. please check below link
[""][1]
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.amirkhan.birthday"
minSdkVersion 15
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation 'com.android.support:appcompat-v7:28.0.0'
}
2)) Maven should be included.
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
google()
}
}

Wallah the problem is solved

[1]: https://mvnrepository.com/artifact/com.android.support/appcompat-v7/28.0.0

最新更新