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

Ger*_*ard 12 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'
Run Code Online (Sandbox Code Playgroud)

但是,在同步时,我收到以下消息:

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
Run Code Online (Sandbox Code Playgroud)

这是我在移动模块中的完整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.+'
}
Run Code Online (Sandbox Code Playgroud)

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

Sco*_*rta 22

如果你有:

compile 'com.google.android.gms:play-services-wearable:5.0.77'
Run Code Online (Sandbox Code Playgroud)

那么你不需要:

compile 'com.google.android.gms:play-services:5.0.77'
Run Code Online (Sandbox Code Playgroud)

删除不可穿戴的.


Mih*_*edi 6

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

com.google.android.gms:play-services- neededDependency:version

例如:如果您使用两个依赖项,如下所述:

compile 'com.google.android.gms:play-services-gcm:7.8.0'
compile 'com.google.android.gms:play-services-ads:8.3.0'
Run Code Online (Sandbox Code Playgroud)

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

compile 'com.google.android.gms:play-services-gcm:7.8.0'
compile 'com.google.android.gms:play-services-ads:7.8.0'
Run Code Online (Sandbox Code Playgroud)

谢谢,希望对您有所帮助.