【问题标题】:Error: more than one library with package name 'android.support.graphics.drawable'错误:多个库的包名称为“android.support.graphics.drawable”
【发布时间】:2018-12-04 02:27:45
【问题描述】:

我正在尝试学习 android studio。在这台电脑上(不是我的)android studio 版本是 2.2.3

当我在 gradle build 时创建一个新项目时发生错误。

错误:任务 ':app:processDebugResources' 执行失败。

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

我一直在寻找这个错误一天。我在任何地方都没有找到相同的主题,所以我必须打开这个帖子。感谢您从现在开始的所有答案。

这是 build.gradle(project:myapplication2)

 buildscript {
 repositories {
     jcenter()
 }
 dependencies {
     classpath 'com.android.tools.build:gradle:2.2.3'

     // NOTE: Do not place your application dependencies here; they belong
     // in the individual module build.gradle files
  }
}
allprojects {
repositories {
    jcenter()
    maven {
       url "https://maven.google.com"
    }
}
}

task clean(type: Delete) {
   delete rootProject.buildDir
}

这是 build.gradle(module:app)

   apply plugin: 'com.android.application'

 android {
compileSdkVersion 28
buildToolsVersion "28.0.0"
defaultConfig {
    applicationId "com.example.alicetin.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'])
  compile 'com.android.support:appcompat-v7:28.+'
  testCompile 'junit:junit:4.12'
}

【问题讨论】:

    标签: android-studio gradle build.gradle


    【解决方案1】:

    试试

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

    而不是

    compile 'com.android.support:appcompat-v7:28.+'
    

    appcompat-v7 版本 28 仍然是 alpha

    【讨论】:

    • 当我按照你的建议尝试后,我得到了这个——Could not find method implementation() for arguments [com.android.support:appcompat-v7:28.0.0] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler
    • @NarendraJi 尝试使用complie,因为implementation 用于较新版本的 Gradle
    【解决方案2】:

    试试

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

    而不是

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

    我遇到了同样的问题,它对我有用。

    【讨论】:

      【解决方案3】:

      用途:

      compile 'com.android.support:appcompat-v7:27.+'
      

      代替:

      compile 'com.android.support:appcompat-v7:28.+'
      

      【讨论】:

        【解决方案4】:

        尽管我的 build.gradle(app) 文件已经更新为 SDK、工具和库的最新生产版本,但我遇到了完全相同的问题。

        唯一需要检查的是 gradle 版本,实际上有一个警告说有更新的 gradle 版本可用。请参考下图。

        more than one library with 'android.support.graphics.drawable'

        升级 gradle 版本后,错误得到解决。

        因此,请将您的 gradle 版本从 2.2.3 升级到更新的版本。

        【讨论】:

          【解决方案5】:

          “com.android.support:appcompat-v7”依赖于“support-vector-drawable” 和 “com.android.support:design”依赖于“animated-vector-drawable”

          将此添加到您的 build.gradle:

          configurations.all {
                  exclude module: 'animated-vector-drawable'
          }
          

          Sush 为:

          dependencies {
              compile fileTree(dir: 'libs', include: ['*.jar'])
              // ...
              configurations.all {
                  exclude module: 'animated-vector-drawable'
              }
          }
          

          【讨论】:

            猜你喜欢
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 2014-06-23
            • 2015-12-26
            • 1970-01-01
            相关资源
            最近更新 更多