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

后端 未结 6 1524
予麋鹿
予麋鹿 2020-12-08 07:02

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

Error:Execution failed for task \':SimpleReader:processDebugResourc

相关标签:
6条回答
  • 2020-12-08 07:26

    this is a problem with versions. if you have multiple dependencies of same package path ensure the versions are the same

    compile 'com.google.android.gms:play-services-ads:8.4.0'
    compile 'com.google.android.gms:play-services-gcm:8.4.0'
    
    0 讨论(0)
  • 2020-12-08 07:31

    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

    0 讨论(0)
  • 2020-12-08 07:47

    I had confused with this problem for a long time.My issue is little different with the question though same error log. I want my sublib's buildtype same with my application's buildtype. So I assigned the buildtype for sublib as the document tells me. [Gradle Plugin User Guide][1]

    This the error I got.

    processing flavorCustomResource

    Error: more than one library with com.xxx.libCommon

    This is my structure. lib1 and lib2 are independent of each other.

    app

    -> lib1 -> libCommon

    -> lib2 -> libCommon

    I got the error only when I build my custom buildtype.However, The release version was Ok.

    More details. some parts of my build.gradle

    app:

    android {
        buildTypes {
            release{}
            custom{}
        }
    }
    configurations {
        flavorReleaseCompile
        flavorCustomCompile
    }
    dependencies{
        compile project(':lib1')
        flavorReleaseCompile project(path: ':lib2', configuration: ':release')
        flavorCustomCompile project(path: ':lib2', configuration: ':custom')
    }
    

    lib1:

    android {
        publishNonDefault true
        buildTypes {
            release{}
            custom{}
        }
    }
    
    dependencies{
        releaseCompile project(path: ':libCommon', configuration: ':release')
        customCompile project(path: ':libCommon', configuration: ':custom')
    }
    

    lib2

    dependencies {
        compile project(':libCommon')
    }
    

    Solution: configure the lib2 as lib1. the problem will be solved.

    lib2:

    android {
        publishNonDefault true
        buildTypes {
            release{}
            custom{}
        }
    }
    
    dependencies{
        releaseCompile project(path: ':libCommon', configuration: ':release')
        customCompile project(path: ':libCommon', configuration: ':custom')
    }
    

    Reason

    The problem is something about Library Publication

    The default publish is release. if lib2 is not configured, it will use the default publish libCommon(release version) which is different from lib1 -> libCommon(custom version) assigned by lib1's build.gradle.This comes the error.

    I wish my post will help someone struggle with the same issue or give some hint to him/her.

    0 讨论(0)
  • 2020-12-08 07:48

    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:

    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
    

    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.

    0 讨论(0)
  • 2020-12-08 07:48

    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.

    0 讨论(0)
  • 2020-12-08 07:52

    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

    0 讨论(0)
提交回复
热议问题