Android 插件冲突错误:Google plus和推送插件
我需要同时使用google plus和推送通知,但Phonegap生成时出错: 请通过更新的版本来修复版本冲突 谷歌服务插件(关于最新版本的信息 可访问bintray.com/android/…)或更新 com.google.android.gms至11.6.2 index.html:Android 插件冲突错误:Google plus和推送插件,android,cordova,phonegap-plugins,phonegap-build,phonegap,Android,Cordova,Phonegap Plugins,Phonegap Build,Phonegap,我需要同时使用google plus和推送通知,但Phonegap生成时出错: 请通过更新的版本来修复版本冲突 谷歌服务插件(关于最新版本的信息 可访问bintray.com/android/…)或更新 com.google.android.gms至11.6.2 index.html: <!DOCTYPE html> <html> <head> <title>Device Ready Example</title>
<!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>
<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" />
设备就绪示例
//等待加载设备API库
//
函数onLoad(){
文件。添加的监听器(“deviceready”,OnDeviceraddy,false);
}
//设备API可用
//
函数ondevicerady(){
//现在可以安全地使用设备API了
var push=PushNotification.init({
“安卓”:{
“发件人ID”:“XXXXXXXXX”
},
});
推送('注册'),功能(数据){
警报('注册事件:'+data.registrationId);
console.log('registration event:'+data.registrationId);
var oldRegId=localStorage.getItem('registrationId');
if(oldRegId!==data.registrationId){
//保存新的注册ID
localStorage.setItem('registrationId',data.registrationId);
//值已更改时将注册ID发布到应用服务器
}
var parentElement=document.getElementById('registration');
var listeningElement=parentElement.querySelector('.waiting');
var receivedElement=parentElement.querySelector('.received');
setAttribute('style','display:none;');
setAttribute('style','display:block;');
});
}
config.xml:
<!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>
<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
通知测试1
sqlchild
播放服务库(
com.google.android.gms
)的cordova插件googleplus
phonegap插件推送Firebase库的
,从而锁定Play Services库的v11.6.2
因此,Play Services库的冲突版本会导致生成错误
phonegap插件推送
现在也转到,它还间接引用了Play Services库
TL;DR:您需要让cordova插件googleplus
指定与phonegap插件推送相同版本的播放服务库
如果您在本地进行建筑,您可以使用:
cordova plugin add cordova-android-play-services-gradle-release --variable PLAY_SERVICES_VERSION=11.6.2
然而,您正在使用Phonegap构建,cordova android play services gradle版本所依赖的Phonegap构建
因此,您最好的解决方案可能是分叉cordova plugin googleplus
,并在plugin.xml
中将Play Services版本设置为11.6.2
,然后在构建中使用该分叉。Ok Dave,谢谢,我会做的,然后回来告诉你:)让你知道,你还可以为我提供构建locally的步骤。我已经完成了插件,但是现在我如何在我的config.xml中使用它呢?我需要在npm上上传它吗?>我需要在npm上上传它吗?
不只是在config.xml中直接从github引用它:
>您还可以为我提供本地构建的步骤吗。参见https://cordova.apache.org/docs/en/latest/guide/cli/index.html
和https://cordova.apache.org/docs/en/latest/guide/platforms/android/index.html
@DaveAlden:嘿,戴夫,你能告诉我如何使用插件吗