Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

What does this error message mean? I don't have duplicated packages in my project

Error:Execution failed for task ':SimpleReader: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

My build.gradle looks like this:

buildscript {

    repositories {
        maven { url 'http://repo1.maven.org/maven2' }
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.9.1'
    }
}
apply plugin: 'android'
android {
    buildToolsVersion '19.0.3'
    defaultConfig {
        minSdkVersion 14
        targetSdkVersion 17

    }
    compileSdkVersion 17
    packagingOptions {
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
    }
    buildTypes {
    }
}
dependencies {
    compile 'com.android.support:support-v4:19.0.1'
    compile 'com.google.android.gms:play-services:4.2.42'
    compile files('libs/gson-2.2.4.jar')
    compile files('libs/httpmime-4.1.jar')
    compile files('libs/httpclient-4.1.1.jar')
    compile files('libs/jsoup-1.7.3.jar')
    compile project(':libraries:actionbarsherlock')
    compile project(':libraries:sherlocknavigationdrawer')
    compile project(':libraries:googleplayservices')
    compile project(':libraries:androidslidinguppanel')
    compile files('libs/protocol-1.0.4.jar')
    compile files('libs/sentry-0.1.4.jar')
    compile files('libs/commons-lang-2.3.jar')
}
like image 706
a.black13 Avatar asked May 06 '14 12:05

a.black13


4 Answers

In my case, the problem was because I was including:

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

both the wearable play services, and the regular. I commented out the wearable part, and it works.
Not sure if I'll need it, but it was included by default by the project wizard

like image 184
Eduard Avatar answered Nov 12 '22 03:11

Eduard


today I met the same problem. I need to use Google Analytics, so I import google analytics lib following the tutorial:

compile 'com.google.android.gms:play-services-analytics:9.0.0'

then compile the project, gradle tell me Error: more than one library with package name 'com.google.android.gms'

I can definitely sure that I only directly import com.google.android.gms one time by google analytics lib.

so I navigate to Project tab in Android Studio to see what are the libs this project depend on, then I found play-services-6.5.87 display in External Libraries, like following screenshot:

see External Libraries

so now I know there is another lib depend on play-services-6.5.87, but I don't which lib it is.

then I use a gradle command in console to see the project dependencies:

$ ./gradlew -q app:dependencies

gradle dependencies

the result tells me that com.facebook.android:audience-network-sdk:4.6.0 depend on it.

so how we fix this problem, two way:

  1. if you don't need this audience-network-sdk, just remove it. my project in fact doesn't need it.
  2. if you also need audience-network-sdk and google-analytics, use exclude group grammar, like following snippet code.

    //facebook SDK
    compile ('com.facebook.android:audience-network-sdk:4.6.0') 
            {exclude group: 'com.google.android.gms'}
    
    // google analytics
    compile 'com.google.android.gms:play-services-analytics:9.0.0'
    

in your case, the audience-network-sdk can be any other lib that depends on same lib with other libs. here is just a thinking of how to resolve similar problems.

like image 16
Spark.Bao Avatar answered Nov 12 '22 02:11

Spark.Bao


Try removing compile project(':libraries:googleplayservices') or compile 'com.google.android.gms:play-services:4.2.42'. I am pretty sure they are the same library.

like image 7
Pieces Avatar answered Nov 12 '22 02:11

Pieces


I faced similar issue, i got it resolved by following steps:

  1. ionic platform rm android

  2. ionic platform add android

  3. ionic build android

like image 1
Ganesh Raj Avatar answered Nov 12 '22 01:11

Ganesh Raj