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

前端 未结 15 1572
清歌不尽
清歌不尽 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

    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.

提交回复
热议问题