【问题标题】:Error: more than one library with package name 'com.google.android.gms'错误:多个库的包名称为“com.google.android.gms”
【发布时间】:2014-07-17 04:48:27
【问题描述】:

我使用的是 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 服务。我该如何解决这个问题?

【问题讨论】:

  • 其中一个库是否可能依赖于另一个库?可能存在传递依赖,所以不需要添加。
  • 这个答案有很大帮助:stackoverflow.com/a/37772331/2371425。您需要确保没有导入多个 com.google.android.gmss。

标签: gradle android-studio wear-os


【解决方案1】:

如果你有:

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

那么你就不需要了:

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

删除不可穿戴的。

【讨论】:

  • 这行得通。错误消失了,我仍然可以使用 Location api。谢谢!
  • 就我而言,import com.google.android.gms.plus.PlusClient 需要compile 'com.google.android.gms:play-services:5.2.08'。所以我删除了可穿戴设备。
【解决方案2】:

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

com.google.android.gms:play-services-neededDependency:版本

例如:如果您同时使用下面提到的两个依赖项:

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'

谢谢,希望对你有帮助。

【讨论】:

  • 这确实有帮助。 com.google.android.gms:play-services 有问题
猜你喜欢
  • 2014-06-23
  • 2015-12-26
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多