Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
737 views
in Technique[技术] by (71.8m points)

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

I'm using Android Studio 0.8.2, and created a project with Android 4.1 and Android Wear 4.4. I need to integrate it with Google Play Services.

I'm trying to follow the Google Play Services setup page for Android Studio here: https://developer.android.com/google/play-services/setup.html

In Step 2, it says to add this dependency:

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

However, upon Sync, I get this message:

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

Here is my complete build.gradle file inside the mobile module:

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.+'
}

It appears that the recommended dependency is conflicting with the wearable compile statement. I do want to retain wearable support, and at the same time need Google Play Services. How do I fix this?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

If you have:

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

then you don't need:

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

Delete the non-wearable one.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...