【问题标题】:Failed to resolve: com.android.support:appcompat-v7:28.+ , Error: more than one library with package name 'android.support.graphics.drawable'无法解决:com.android.support:appcompat-v7:28.+,错误:多个库的包名称为“android.support.graphics.drawable”
【发布时间】:2018-07-16 21:30:17
【问题描述】:

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

我尝试清理项目,使现金/重启无效并删除 .idea,但还是一样

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

我尝试添加

行家{
网址'https://maven.google.com/' 名称“谷歌” }

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

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

Error Photo

最后我尝试将“appcompat-v7:28.+”更改为“appcompat-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'
}

【问题讨论】:

    标签: java android


    【解决方案1】:

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

    并在下面添加依赖项

    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'
    

    【讨论】:

      【解决方案2】:

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

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

      更新:现在你又犯了另一个错误:

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

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

      【讨论】:

      • 我试过了,它显示这个问题“错误:任务':app:processDebugResources'的执行失败。>错误:包名称为'android.support.graphics.drawable'的库不止一个”
      • @AhmedHassan 现在你转向另一个问题。我更新了答案。
      • @AhmedHassan 如果这个答案对您有帮助,您可以接受它,以便其他人更容易找到它。
      【解决方案3】:

      如果你正在使用

          compileSdkVersion 28
      

      在代码下方添加你的依赖项

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

      这是link

      【讨论】:

        【解决方案4】:

        试试这个,希望它有效

        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
        

        【讨论】:

        • 成功了!我以为这两个不兼容:implementation 'com.android.support:appcompat-v7:28.0.0' implementation 'com.android.support:support-v4:28.0.0' ...我错了!
        【解决方案5】:

        试试这个代码,希望它能工作。谢谢

        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')
        

        }

        【讨论】:

          【解决方案6】:

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

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

          android.uniquePackageNames = true

          你会看到错误

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

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

          【讨论】:

            【解决方案7】:
                    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
            

            【讨论】:

            • 尽量在一行中解释你的代码是什么。
            • implementation 'com.android.support:appcompat-v7:28.0.0' 你应该包括 maven { url "maven.google.com" }
            • 这是一个重复的答案。
            猜你喜欢
            • 2018-12-04
            • 2017-01-03
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 2018-01-03
            相关资源
            最近更新 更多