Search code examples
androidcordovaphonegap-pluginsphonegap-buildphonegap

Plugin conflict error : Google plus and Push plugin


I need to used google plus and push notification both but Phonegap Build gives error :

Please fix the version conflict either by updating the version of the google-services plugin (information about the latest version is available at bintray.com/android/…) or updating the version of com.google.android.gms to 11.6.2.

index.html :

<!DOCTYPE html>
<html>
  <head>
    <title>Device Ready Example</title>

    <script type="text/javascript" charset="utf-8" src="cordova.js"></script>
    <script type="text/javascript" src="push.js"></script> 


    <script> 

    // Wait for device API libraries to load
    //
    function onLoad() {
        document.addEventListener("deviceready", onDeviceReady, false);
    }

    // device APIs are available
    //
    function onDeviceReady() {
        // Now safe to use device APIs
        var push = PushNotification.init({
            "android": {
              "senderID": "xxxxxxxxxx"
            },
        });


    push.on('registration', function(data) {
        alert('registration event: ' + data.registrationId);
        console.log('registration event: ' + data.registrationId);

        var oldRegId = localStorage.getItem('registrationId');
        if (oldRegId !== data.registrationId) {
        // Save new registration ID
        localStorage.setItem('registrationId', data.registrationId);
        // Post registrationId to your app server as the value has changed
     }

    var parentElement = document.getElementById('registration');
    var listeningElement = parentElement.querySelector('.waiting');
    var receivedElement = parentElement.querySelector('.received');

    listeningElement.setAttribute('style', 'display:none;');
    receivedElement.setAttribute('style', 'display:block;');
  });
}

    </script>
  </head>
  <body onload="onLoad()">
  </body>
</html>

config.xml :

    <widget id="com.phonegap.notificationtest1" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:gap="http://phonegap.com/ns/1.0">
        <name>notificationtest1</name>
        <description>
         notificationtest1
        </description>
        <author email="[email protected]" href="http://phonegap.com">
            sqlchild
        </author> 


            <preference name="android-minSdkVersion" value="17" /> 

            <preference name='phonegap-version' value='cli-8.0.0' />

            <preference name='pgb-builder-version' value='2' />



    <plugin name="phonegap-plugin-push" spec="2.1.3">   
            <param name="SENDER_ID" value="xxxxxxxxxxxx" />
    </plugin> 


        <plugin name="cordova-plugin-googleplus" source="npm" spec="5.3.0"></plugin>  


        <platform name="android">   

            <resource-file src="app/google-services.json" target="app/google-services.json" />  

        </platform>      


        <content src="index.html" />


Solution

  • cordova-plugin-googleplus currently pins v11.8.0 of the Play Services library (com.google.android.gms).

    phonegap-plugin-push currently pins v11.6.2 of the Firebase library which in turn pins v11.6.2 of the Play Services Library.

    Hence the conflicting versions of the Play Services library are causing your build error.

    phonegap-plugin-push also now depends on cordova-support-google-services to pull in v3.2.0 of the Google Services plugin, which also indirectly references the Play Services library.

    TL;DR: you need to make cordova-plugin-googleplus specify the same version of the Play Services library as phonegap-plugin-push.

    If you were building locally, you could use cordova-android-play-services-gradle-release to do this:

    cordova plugin add cordova-android-play-services-gradle-release  --variable PLAY_SERVICES_VERSION=11.6.2
    

    However, you're building with Phonegap Build which doesn't support the execution of hooks scripts on which cordova-android-play-services-gradle-release relies.

    So your best solution is probably to fork cordova-plugin-googleplus and set the Play Services version to 11.6.2 in plugin.xml, then use that fork in your build.