• Stars
    star
    110
  • Rank 316,770 (Top 7 %)
  • Language
    JavaScript
  • Created over 7 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Cordova/Phonegap plugin for Android to align versions of the Play Services library components specified by other plugins to a specific version.

cordova-android-play-services-gradle-release Latest Stable Version Total Downloads

Cordova/Phonegap plugin for Android to align versions of the Play Services library components specified by other plugins to a specific version.

Table of Contents

Purpose

TL;DR: To prevent build failures caused by including different versions of Play Services library components.

Some Cordova plugins include the Play Services library to faciliate them. Most commonly, these are now included into the Cordova project by specifying them as Gradle dependencies (see the Cordova plugin spec documenation).

Example plugins:

The problem arises when these plugins specify different versions of the Play Services library components. This can cause build failures to occur, which are not easy to resolve without changes by the plugin authors to align the specified versions. See these issues:

To resolve these version collisions, this plugin injects a Gradle configuration file into the native Android platform project, which overrides any versions specified by other plugins, and forces them to the version specified in its Gradle file.

If you're encountering similar problems with the Android Support and/or Firebase libraries, checkout the sister plugins:

Caveats

Other plugins that reference the Firebase library

Other plugins that reference the Google Services plugin

  • There are certain Cordova plugins which reference the Google Services plugin in their Gradle config, for example:
  • The Google Services plugin itself references a particular version of the Play Services library
    • The version of Play Services library referenced depends on the version of the Google Services plugin referenced by the Cordova plugin.
  • If a plugin (such as cordova-plugin-fcm) is included into a Cordova project along with this plugin, then this plugin is unable to override the Play Services library version specified by the Google Services plugin.
  • Attempting to do this will result in a build failure with an error message such as Found com.google.android.gms:play-services-location:12.+, but version 9.0.0 is needed for the google-services plugin.
  • The only solution you can implement using this plugin is to specify the same version as required by the Google Services plugin
    • In the example error above, that would mean installing this plugin with: cordova plugin add cordova-android-play-services-gradle-release --variable play-services-location=9.0.0

Requirements

This plugin requires cordova@8+ (CLI) and cordova-android@7+ (Android platform). Since the plugin uses hook scripts it will not work in Cloud Build environments such as Phonegap Build.

Installation

# override using default component versions
$ cordova plugin add cordova-android-play-services-gradle-release

# override using custom component versions 
$ cordova plugin add cordova-android-play-services-gradle-release  --variable play-services-location=17.0.0

Component versions

This plugin enables overriding the version of the following Play Services library components:

com.google.android.gms:play-services-ads
com.google.android.gms:play-services-ads-identifier
com.google.android.gms:play-services-ads-lite
com.google.android.gms:play-services-afs-native
com.google.android.gms:play-services-analytics
com.google.android.gms:play-services-analytics-impl
com.google.android.gms:play-services-appinvite
com.google.android.gms:play-services-audience
com.google.android.gms:play-services-auth
com.google.android.gms:play-services-auth-api-phone
com.google.android.gms:play-services-awareness
com.google.android.gms:play-services-base
com.google.android.gms:play-services-basement
com.google.android.gms:play-services-cast
com.google.android.gms:play-services-cast-framework
com.google.android.gms:play-services-clearcut
com.google.android.gms:play-services-cronet
com.google.android.gms:play-services-drive
com.google.android.gms:play-services-fido
com.google.android.gms:play-services-fitness
com.google.android.gms:play-services-flags
com.google.android.gms:play-services-games
com.google.android.gms:play-services-gass
com.google.android.gms:play-services-gcm
com.google.android.gms:play-services-identity
com.google.android.gms:play-services-iid
com.google.android.gms:play-services-instantapps
com.google.android.gms:play-services-location
com.google.android.gms:play-services-maps
com.google.android.gms:play-services-measurement
com.google.android.gms:play-services-measurement-api
com.google.android.gms:play-services-measurement-impl
com.google.android.gms:play-services-measurement-sdk
com.google.android.gms:play-services-measurement-sdk-api
com.google.android.gms:play-services-nearby
com.google.android.gms:play-services-oss-licenses
com.google.android.gms:play-services-panorama
com.google.android.gms:play-services-phenotype
com.google.android.gms:play-services-places
com.google.android.gms:play-services-places-placereport
com.google.android.gms:play-services-plus
com.google.android.gms:play-services-safetynet
com.google.android.gms:play-services-stats
com.google.android.gms:play-services-tagmanager
com.google.android.gms:play-services-tagmanager-api
com.google.android.gms:play-services-tagmanager-v4-impl
com.google.android.gms:play-services-tasks
com.google.android.gms:play-services-vision
com.google.android.gms:play-services-vision-common
com.google.android.gms:play-services-vision-image-label
com.google.android.gms:play-services-wallet
com.google.android.gms:play-services-wearable

Default version

By default, this plugin pins a recent version of each of the Play Services library components. You can see what the currently pinned versions are by looking at the <preference>'s in the plugin.xml.

Other versions

You may want to specify a version of the Play Services library components - see here for a list recent versions.

Library component versions are specified in the Android build as Gradle artifacts in the format packageId:componentId:versionNumber, for example com.google.android.gms:play-services-location:17.0.0. To override the default version when installing this plugin, specify a plugin variable where the variable key is the component ID and the value is the version number. For example, if you want to install v17.0.0 of the Play Services library Location component, you'd specify the version via the variable:

cordova plugin add cordova-android-play-services-gradle-release --variable play-services-location=17.0.0

You can also specify the the overrides directly in the config.xml and this plugin will find them, for example:

<plugin name="cordova-android-play-services-gradle-release" spec="^4.0.0">
    <variable name="play-services-location" value="17.0.0" />
</plugin>

Or in the package.json, e.g.:

{
    "cordova": {
        "plugins": {
            "cordova-android-play-services-gradle-release": {
                "play-services-location": "17.0.0"
            }
        }
    }
}           

Note: the plugin is case-insensitive to the component ID so PLAY-SERVICES-LOCATION or play-services-location will both work.

Credits

Thanks to Chris Scott, Transistor Software for his idea of extending the initial implementation to support dynamic specification of the library version via a plugin variable in cordova-google-api-version

License

The MIT License

Copyright (c) 2017 Dave Alden / Working Edge Ltd.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

More Repositories

1

phonegap-launch-navigator

Phonegap/Cordova plugin which launches native route navigation apps for Android, iOS and Windows
Objective-C
368
star
2

cordova-custom-config

Cordova/Phonegap plugin to update platform configuration files based on preferences and config-file data defined in config.xml
JavaScript
317
star
3

cordova-android-support-gradle-release

Cordova/Phonegap plugin to align various versions of the Android Support libraries specified by other plugins to a specific version
JavaScript
230
star
4

cordova-check-plugins

A CLI tool to check for / manage plugin updates in Cordova/Phonegap projects.
JavaScript
216
star
5

react-native-launch-navigator

A React Native module for launching today's most popular navigation/ride apps to navigate to a destination.
Java
120
star
6

cordova-plugin-androidx-adapter

Cordova/Phonegap plugin to migrate any code which references the legacy Android Support Library to the new AndroidX mappings in a Cordova Android platform project.
JavaScript
110
star
7

cordova-plugin-request-location-accuracy

Cordova/Phonegap plugin for Android and iOS to request enabling/changing of Location Services by triggering a native dialog
Java
95
star
8

cordova-launch-review

Cordova/Phonegap plugin for iOS and Android to assist in leaving user reviews/ratings in the App Stores
Objective-C
70
star
9

cordova-sqlite-porter

Cordova/Phonegap plugin to import/export a SQLite database using either SQL or JSON.
JavaScript
66
star
10

cordova-plugin-androidx

Cordova/Phonegap plugin to enable AndroidX
JavaScript
43
star
11

cordova-plugin-firebasex-test

A Cordova app project to test cordova-plugin-firebasex
JavaScript
34
star
12

phonegap-launch-navigator-example

Example project illustrating how to use the Cordova Launch Navigator plugin for Android/iOS/Windows
JavaScript
31
star
13

cordova-android-firebase-gradle-release

Cordova/Phonegap plugin for Android to align versions of the Firebase library components specified by other plugins to a specific version.
JavaScript
28
star
14

phonegap-istablet

Cordova/Phonegap plugin to determine if current device is a tablet
Objective-C
27
star
15

cordova-custom-config-example

An example Cordova/Phonegap project that demonstrates use of the cordova-custom-config plugin
JavaScript
24
star
16

cordova-plugin-crosswalk-data-migration

Cordova/Phonegap plugin for Android to preserve persistent webview data after removing Crosswalk from your app.
Java
23
star
17

cordova-plugin-inappbrowser-popup-bridge

A fork of cordova-plugin-inappbrowser which adds Braintree's PopupBridge functionality to support PayPal payments
Objective-C
22
star
18

cordova-diagnostic-plugin-example

Demonstrates use of Diagnostic plugin
JavaScript
19
star
19

cordova-plugin-inappbrowser-wkwebview

[DEPRECATED] A fork of cordova-plugin-inappbrowser which is powered by WKWebView
Objective-C
15
star
20

cordova-plugin-hello-kotlin

A simple example of a Cordova plugin that uses Kotlin on Android
JavaScript
13
star
21

cordova-plugin-request-location-accuracy-example

An example app that demonstrates use of cordova-plugin-request-location-accuracy
JavaScript
10
star
22

cordova-plugin-inappbrowser-test

JavaScript
7
star
23

cordova-plugin-firebasex-ionic3-test

CSS
6
star
24

cordova-plugin-hello-c-test

Test project for cordova-plugin-hello-c
JavaScript
5
star
25

cordova-plugin-inappbrowser-popup-bridge-test

Demonstrates usage of Braintree's PopupBridge via the Cordova InappBrowser to add support for emulated popups for PayPal payments
JavaScript
5
star
26

cordova-launch-review-example

Example project illustrating how to use the cordova-launch-review Cordova/Phonegap plugin for Android/iOS
HTML
4
star
27

cordova-sqlite-porter-example-native-plugin

JavaScript
3
star
28

cordova-plugin-config-command

Cordova/Phonegap plugin to run CLI commands defined in config.xml
JavaScript
3
star
29

cordova-sqlite-porter-example

JavaScript
2
star
30

stereoscopic-slideshow

Example slideshow to render stereoscopic side-by-side images in 3D using a VR headset
JavaScript
2
star
31

cordova-diagnostic-plugin-ionic-example

Demonstrates use of Diagnostic plugin with Ionic framework
TypeScript
2
star
32

cordova-plugin-cloud-settings-test

An example project that illustrates usage of the cordova-plugin-cloud-settings plugin.
JavaScript
1
star
33

cordova-plugin-inappbrowser-wkwebview-test

Test app project for cordova-plugin-inappbrowser-wkwebview
HTML
1
star