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

前端 未结 15 1425
清歌不尽
清歌不尽 2020-12-09 15:59

When I try to run the command ionic cordova build android out error as title above. Then I try to remove one of the gms, when I build again the del

相关标签:
15条回答
  • 2020-12-09 16:03

    I've faced this issue quite recently and the problem for me was that for some reason the android project.properties file was generated with different versions for the com.google.android.gms, as such:

    target=android-26
    android.library.reference.1=CordovaLib
    cordova.system.library.1=com.android.support:support-v4:24.1.1+
    cordova.system.library.2=com.google.android.gms:play-services-auth:+
    cordova.system.library.3=com.google.android.gms:play-services-identity:+
    cordova.system.library.4=com.google.android.gms:play-services-location:11.+
    

    This makes the library.2 and library.3 require one version while the library.4 requires a more specific version, thus causing the duplicate library reference during compiling.

    While I don't think this should be the final solution, adding the specific library worked for me. As such:

    target=android-26
    android.library.reference.1=CordovaLib
    cordova.system.library.1=com.android.support:support-v4:24.1.1+
    cordova.system.library.2=com.google.android.gms:play-services-auth:11.+
    cordova.system.library.3=com.google.android.gms:play-services-identity:11.+
    cordova.system.library.4=com.google.android.gms:play-services-location:11.+
    
    0 讨论(0)
  • 2020-12-09 16:03

    Maybe it related to new release of Google Play services 12.0.0(released at March 20, 2018) I've resolved it fixing dependencies: Add config in android/build.gradle

    allprojects {
    repositories {
        ...
        configurations.all {
            resolutionStrategy {
                // Add force (11.0.0 is version you want to use)
                 force 'com.google.firebase:firebase-core:11.0.0'
                force 'com.google.firebase:firebase-crash:11.0.0'
                force 'com.google.firebase:firebase-analytics:11.0.0'
                force 'com.google.firebase:firebase-messaging:11.0.0'
                force 'com.google.android.gms:play-services-base:11.0.0'
                force 'com.google.android.gms:play-services-maps:11.0.0'
                force 'com.google.android.gms:play-services-wallet:11.0.0'
            }
        }
    }
    }
    

    Set of dependencies are from your android/app/build.gradle

    0 讨论(0)
  • 2020-12-09 16:03

    For reference, from: https://developers.google.com/android/guides/releases

    Google APIs for Android

    March 20, 2018 - Version 12.0.0

    Known Issues with version 12.0.0

    • ...
    • -license POM dependencies cause "more than one library with package name ‘com.google.android.gms.license'" issues in Ionic Pro.
    • ...

    We will provide an updated 12.0.1 release to address these issues soon.


    My Workaround

    (based on jeremy castelli's answer and keldar's subsequent comment)

    I am using the following workaround (and I stress, this is a workaround).

    Add the following to the bottom of build-extras.gradle, creating the file if necessary.

    configurations.all {
      resolutionStrategy {
        force 'com.google.firebase:firebase-core:11.8+',
          'com.google.firebase:firebase-messaging:11.8+',
          'com.google.firebase:firebase-crash:11.8+',
          'com.google.firebase:firebase-config:11.8+',
          'com.google.firebase:firebase-auth:11.8+',
          'com.google.android.gms:play-services-tagmanager:11.8+',
          'com.google.android.gms:play-services-location:11.8+'
      }
    }
    

    It is important to include all firebase and all android.gms library references, if you miss just one from here, it will still fail to build. Grep your gradle files for all the references. In my case I had missed firebase-auth which was referenced in the firebase plugin folder's .gradle file.

    What resolutionStrategy force does is override the version choices made by the project/plugins and force gradle to reference a specific version.

    There is no need to edit project.properties or any other gradle files using this workaround.

    0 讨论(0)
  • 2020-12-09 16:07

    in build.gradle add this

    configurations.all {
       resolutionStrategy {
           force "com.google.android.gms:play-services-ads:11.8.0"
           force "com.google.android.gms:play-services-base:11.8.0"
           force "com.google.android.gms:play-services-gcm:11.8.0"
           force "com.google.android.gms:play-services-analytics:11.8.0"
           force "com.google.android.gms:play-services-location:11.8.0"
           force "com.google.android.gms:play-services-basement:11.8.0"
           force "com.google.android.gms:play-services-tagmanager:11.8.0"
           force 'com.google.firebase:firebase-core:11.8.0'
           force 'com.google.firebase:firebase-crash:11.8.0'
           force 'com.google.firebase:firebase-auth:11.8.0'
           force 'com.google.firebase:firebase-common:11.8.0'
           force 'com.google.firebase:firebase-config:11.8.0'
           force 'com.google.firebase:firebase-messaging:11.8.0'
       }
    }
    

    if that doesn't work, search in your project the string '12.0.0' and add in the list above the missing library

    0 讨论(0)
  • 2020-12-09 16:10

    In my case

    npm update
    cordova platform remove android
    cordova platform add android@6.4.0
    

    And replace in platform/android/projet.properties

    cordova.system.library.1=com.android.support:support-v4+
    

    To

    cordova.system.library.1=com.android.support:support-v4:26+
    
    0 讨论(0)
  • 2020-12-09 16:11

    UPDATE

    The cause of this error has been identified as a bug in v12.0.0 of the Google Play Services library:

    Known Issues with version 12.0.0 -license POM dependencies cause "more than one library with package name ‘com.google.android.gms.license'" issues in Ionic Pro.

    The bug has been fixed in v12.0.1 of the Google Play Services library:

    Restores unique package names for runtime linked -license artifacts which affected some build systems' (e.g. Ionic Pro) compatibility issues.

    Therefore specifying v12.0.1 or above of the Play Services Library via the cordova-android-play-services-gradle-release plugin resolves the issue, for example:

    cordova plugin add cordova-android-play-services-gradle-release  --variable PLAY_SERVICES_VERSION=12.+
    
    0 讨论(0)
提交回复
热议问题