Java 无法解析:com.android.support:appcompat-v7:28.+,错误:多个库的包名为“android.support.graphics.drawable”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/51370352/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-11 00:06:03  来源:igfitidea点击:

Failed to resolve: com.android.support:appcompat-v7:28.+ , Error: more than one library with package name 'android.support.graphics.drawable'

javaandroid

提问by Ahmed Hassan

I'm new to Android Studio, I tried everything to solve this problem "Failed to resolve: com.android.support:appcompat-v7:28.+ "

我是 Android Studio 的新手,我尝试了一切来解决这个问题“无法解决:com.android.support:appcompat-v7:28.+”

I tried to clean project , invalidate cash/restart and removing .idea and still the same

我试图清理项目,使现金/重启无效并删除 .idea,但仍然相同

I'm using android studio 2.2.1 for a learning reason , and I updated it to android studio 3 and there a multiple rendering problems so I returned back to version 2.2.1

出于学习原因,我正在使用 android studio 2.2.1,我将其更新为 android studio 3,但存在多个渲染问题,因此我返回到版本 2.2.1

I tried to add

我试着添加

maven {
url 'https://maven.google.com/' name 'Google' }

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

So,It stuck with another problem

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

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

Error Photo

错误照片

Finally I tried to change "appcompat-v7:28.+" to "appcompat-v7:27" and it' works but still tell me that i should use the same library to avoid mistakes

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

This is my Gradle code:

这是我的 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'
}

回答by Moradnejad

try adding this to your code:

尝试将其添加到您的代码中:

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

Update: Now you moved on to another error:

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

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

错误:包名为“android.support.graphics.drawable”的库不止一个...

To fix this, you need to change compileto implementationin dependenciespart.

为了解决这个问题,您需要更改compileimplementationdependencies部分。

回答by Anant Shah

if you are using

如果你正在使用

    compileSdkVersion 28

add in your dependencies below code

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

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

this is the link

这是链接

回答by Najib Ahmed Puthawala

Try this one, hope it is working

试试这个,希望它有效

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'

dependencies

依赖

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

android

安卓

  compileSdkVersion 28
  minSdkVersion 21
  targetSdkVersion 28

回答by Najib Ahmed Puthawala

Try this code, hope it will be working. Thanks

试试这个代码,希望它会起作用。谢谢

build.gradle (Project)

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 (app)

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 check for implementation

依赖检查实现

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

}

}

回答by Roshan

Replace 'com.android.support:appcompat-v7:28+'by 'com.android.support:appcompat-v7:28.0.0'

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

and add below dependencies

并添加以下依赖项

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'

回答by Sungsuh Park

I found that 'com.android.support:animated-vector-drawable' and 'com.android.support:support-vector-drawable' have a same package name in support library version 28.0.0. Normally this does not make the problem.

我发现 'com.android.support:animated-vector-drawable' 和 'com.android.support:support-vector-drawable' 在支持库版本 28.0.0 中具有相同的包名称。通常这不会造成问题。

But if you have the following line in gradle.properties

但是,如果您在 gradle.properties 中有以下行

android.uniquePackageNames = true

android.uniquePackageNames = true

you will see the error

你会看到错误

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

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

If you should use the uniquePackageNames option, use androidx instead of support library 28.0.0.

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

回答by amir khan

        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