错误:包含名称为“com.google.android.gms”的多个库

时间:2014-07-17 04:48:28

标签: gradle android-studio wear-os

我正在使用Android Studio 0.8.2,并使用Android 4.1和Android Wear 4.4创建了一个项目。我需要将其与Google Play服务集成。

我尝试在此处关注Android Studio的Google Play服务设置页面: https://developer.android.com/google/play-services/setup.html

在第2步中,它说要添加此依赖项:

compile 'com.google.android.gms:play-services:5.0.77'

然而,在同步时,我收到此消息:

Error:Execution failed for task ':mobile:processDebugResources'.
> Error: more than one library with package name 'com.google.android.gms'
  You can temporarily disable this error with android.enforceUniquePackageName=false
  However, this is temporary and will be enforced in 1.0

这是我在移动模块中的完整build.gradle文件:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 20
    buildToolsVersion "20.0.0"

    defaultConfig {
        applicationId "com.OptimizedPrime.locationweartabs"
        minSdkVersion 16
        targetSdkVersion 20
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            runProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    wearApp project(':wear')
    compile 'com.google.android.gms:play-services-wearable:+'
    compile 'com.google.android.gms:play-services:5.0.77'
    // You must install or update the Support Repository through the SDK manager to use this dependency.
    compile 'com.android.support:support-v13:19.+'
}

推荐的依赖项似乎与可穿戴的编译语句冲突。我确实希望保留可穿戴支持,同时需要Google Play服务。我该如何解决这个问题?

2 个答案:

答案 0 :(得分:22)

如果你有:

compile 'com.google.android.gms:play-services-wearable:5.0.77'

然后你不需要:

compile 'com.google.android.gms:play-services:5.0.77'

删除不可穿戴设备。

答案 1 :(得分:6)

可能您正在使用的是具有不同版本的不同类型的依赖项:

  

com.google.android.gms:玩-服务 - 的 neededDependency :<强> 版本

Ex:如果您正在使用这两个依赖项,请参阅下文:

compile 'com.google.android.gms:play-services-gcm:7.8.0'
compile 'com.google.android.gms:play-services-ads:8.3.0'

尝试对不同的依赖项使用相同的版本,例如:

compile 'com.google.android.gms:play-services-gcm:7.8.0'
compile 'com.google.android.gms:play-services-ads:7.8.0'

谢谢,希望对你有所帮助。