How to fix duplicate libraries - more than one library with package name 'android.support.v7.appcompat'

烈酒焚心 提交于 2019-12-07 15:37:58

问题


Gradle build error - more than one library with package name android.support.v7.appcompat. This project has Chrome Cast in it, so is using android-support-v7-appcompat and CastCompanionLibary-android-master. Project structure is the following:

  • BaseGameUtils
  • CastCompanionLibrary-android-master
  • VideoBrowserActivity
  • android-support-v7-appcompat
  • android-support-v7-mediarouter
  • google-play-services_lib

Really tough error because the compiler doesn't give much information other than 'more than one library with package name 'android.support.v7.appcompat'. Understand why you don't want to be using different versions of the same library, but why doesn't the compiler reveal what versions are being used, and where they are being called from?

Trying to add leaderboard similar to type-a-number challenge (github example project)

There are a total of (7) build.gradle files. One for the top level and one for each of the packages listed above. Top level gradle file:

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {

repositories {
    mavenCentral()
}
dependencies {
    classpath 'com.android.tools.build:gradle:1.0.0'
}

BaseGameUtils:

dependencies {
    compile 'com.android.support:appcompat-v7:20.0.+'
    compile 'com.android.support:support-v4:20.0.+'
    compile 'com.google.android.gms:play-services-games:6.5+'
    compile 'com.google.android.gms:play-services-plus:6.5+'
    compile 'com.google.android.gms:play-services-appstate:6.5+'
}

CastCompanionLibrary-android-master

dependencies {
    compile fileTree(dir: 'libs', include: '*.jar')
    compile 'com.android.support:appcompat-v7:20.0.+'
    compile project(':android-support-v7-mediarouter')
    compile 'com.google.android.gms:play-services-cast:6.5+'
    compile project(':BaseGameUtils')
}

VideoBrowserActivity

dependencies {
    compile fileTree(dir: 'libs', include: '*.jar')
    compile project(':CastCompanionLibrary-android-master')
}

android-support-v7-appcompat

dependencies {
    compile fileTree(dir: 'libs', include: '*.jar')
}

android-support-v7-mediarouter

dependencies {
    compile fileTree(dir: 'libs', include: '*.jar')
    compile project(':android-support-v7-appcompat')
}

google-play-services_lib

dependencies {
    compile fileTree(dir: 'libs', include: '*.jar')
}

Any help is appreciated on this.


回答1:


Just go through you project's libs folder not from the Android Studio but from you windows explorer/finder (for windows)/(for mac). And search for android.support.v7.appcompat. Any evidence found related to Apcompat (whether it is v4 or v7) is recommended to be deleted.

Hopefully your problem will be solved.

In your libs folder dont miss any sub directory that has libs folder.



来源:https://stackoverflow.com/questions/29175908/how-to-fix-duplicate-libraries-more-than-one-library-with-package-name-androi

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!