错误:多个包含软件包名称的库' com.google.android.gms'。什么都没有帮助

时间:2016-04-17 09:29:15

标签: android

首先,我想说我已经搜索了这个问题,但没有任何帮助。 我有一个项目和一个图书馆。 Project的依赖项如下所示:

dependencies {
    compile fileTree(include: '*.jar', dir: 'libs')        
    compile 'com.google.android.gms:play-services-identity:8.4.0'
    compile 'com.google.android.gms:play-services-gcm:8.4.0'
    compile ('org.mycompany.mylib:gmapslib:1.0.5') {
        transitive = false;
    }

和库的依赖项(org.mycompany.mylib:gmapslib):

dependencies {          
    compile 'com.google.android.gms:play-services-maps:8.4.0'
    compile 'com.android.support:support-v4:23.0.1'
}

但是,当我尝试构建项目时,我得到了这个:

Error: more than one library with package name 'com.google.android.gms'

以下是gradlew app:dependencies

的结果
_debugCompile - ## Internal use, do not manually configure ##
+--- com.android.support:multidex:1.0.1
+--- ru.yandex:yandexmapkit:1.0.0
+--- com.google.android.gms:play-services-identity:8.4.0
|    \--- com.google.android.gms:play-services-base:8.4.0
|         \--- com.google.android.gms:play-services-basement:8.4.0
|              \--- com.android.support:support-v4:23.0.0 -> 23.3.0
|                   \--- com.android.support:support-annotations:23.3.0
+--- com.google.android.gms:play-services-gcm:8.4.0
|    +--- com.google.android.gms:play-services-base:8.4.0 (*)
|    \--- com.google.android.gms:play-services-measurement:8.4.0
|         \--- com.google.android.gms:play-services-basement:8.4.0 (*)
+--- org.mycompany.mylib:gmapslib:1.0.6
+--- org.apache.commons:commons-net:3.3
+--- com.android.support:support-v4:23.0.1 -> 23.3.0 (*)
\--- com.android.support:appcompat-v7:23.3.0
     +--- com.android.support:support-vector-drawable:23.3.0
     |    \--- com.android.support:support-v4:23.3.0 (*)
     +--- com.android.support:animated-vector-drawable:23.3.0
     |    \--- com.android.support:support-vector-drawable:23.3.0 (*)
     \--- com.android.support:support-v4:23.3.0 (*)

这很疯狂,不是吗?如果我在3个库以及主项目中有谷歌播放服务依赖项怎么办?在这种情况下我该怎么办?那太荒谬了。

1 个答案:

答案 0 :(得分:1)

我认为org.mycompany.mylib:gmapslib:1.0.5也包含com.google.android.gms,所以请尝试这样:

dependencies {
   compile fileTree(include: '*.jar', dir: 'libs')        
   compile 'com.google.android.gms:play-services-identity:8.4.0'
   compile 'com.google.android.gms:play-services-gcm:8.4.0'
   compile ('org.mycompany.mylib:gmapslib:1.0.5') {
       transitive = false
       exclude group: 'com.google.android.gms'
}