Ошибка конфликта плагинов: плагин Google plus и Push - PullRequest
0 голосов
/ 22 мая 2018

Мне нужно использовать google plus и push-уведомление, но Phonegap Build выдает ошибку :

Исправьте конфликт версий, либо обновив версию плагина google-services(информация о последней версии доступна на bintray.com/android/…) или обновлении версии com.google.android.gms до 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="support@phonegap.com" 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" />

1 Ответ

0 голосов
/ 22 мая 2018

cordova-plugin-googleplus в настоящее время pins v11.8.0 библиотеки Play Services (com.google.android.gms).

phonegap-plugin-push в настоящее время pins v11.6.2 изБиблиотека Firebase, которая, в свою очередь, прикрепляет v11.6.2 библиотеки Play Services.

Следовательно, конфликтующие версии библиотеки Play Services вызывают ошибку вашей сборки.

phonegap-plugin-push также теперь зависит от cordova-support-google-services до версии 3.2.0 подключаемого модуля служб Google , который также косвенно ссылается на библиотеку служб Play Services.

TL; DR: вам нужно заставить cordova-plugin-googleplus указывать ту же версию библиотеки Play Services, что и phonegap-plugin-push.

Если вы строили локально, вы могли бы использовать cordova-android-play-services-gradle-release для этого:

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

Однако вы строите с помощью Phonegap Build, который не поддерживает выполнение сценариев перехвата , для которых cordova-android-play-services-gradle-release полагается.

Таким образом, ваше лучшее решение, вероятно, состоит в том, чтобы форк cordova-plugin-googleplus и установить Pположите версию Services в 11.6.2 в plugin.xml, затем используйте эту вилку в вашей сборке.

...