我实施新的谷歌云消息之后从谷歌开发者页面的导游在这里
我已成功运行并测试它.但我现在的问题是我有不同的productFlavors具有不同的applicationId/packageName和不同的GCM项目ID.在google-services.json具有在被投入/app/google-services.json不是味道文件夹.
有没有办法让google-services.json配置与许多口味不同?
我在Android Studio 2.2 Preview 1中使用Android App和Backend模块在Google Messaging中创建了一个新项目.这是应用程序文件:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "com.xxx.xxx"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha1'
compile 'com.google.android.gms:play-services-gcm:9.0.0'
testCompile 'junit:junit:4.12'
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2'
androidTestCompile 'com.android.support.test:runner:0.5'
androidTestCompile 'com.android.support:support-annotations:23.4.0'
compile project(path: ':backend', configuration: 'android-endpoints')
}
Run Code Online (Sandbox Code Playgroud)
但它给了:
错误:与依赖项'com.google.code.findbugs:jsr305'冲突.app(1.3.9)和测试app(2.0.1)的已解决版本有所不同.有关详细信息,请参阅http://g.co/androidstudio/app-test-app-conflict.
我是Android的新手,无法找到这个错误.我如何解决它?
gradle google-cloud-messaging android-studio build.gradle android-gradle-plugin
如何在PHP后端中集成新的Google Cloud Messaging?
所以今天早上我开始更新到我的项目库的最新版本.
我正在尝试将GCM更新到最新版本9.2.0,但是我收到此错误:
错误:任务':app:processDebugGoogleServices'的执行失败.请通过更新google-services插件的版本来修复版本冲突(有关最新版本的信息,请访问https://bintray.com/android/android-tools/com.google.gms.google-services/)或将com.google.android.gms的版本更新为9.0.0.
这就是我的代码:
dependencies {
classpath 'com.android.tools.build:gradle:2.1.2'
classpath 'com.google.gms:google-services:3.0.0'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
}
Run Code Online (Sandbox Code Playgroud)
然后:
dependencies {
...
compile "com.google.android.gms:play-services-gcm:9.2.0"
...
}
Run Code Online (Sandbox Code Playgroud)
任何人有同样的问题/修复同样的问题?
谢谢.
编辑
显然你必须在app/build.gradle文件的底部应用你的GSM插件.否则,版本9.2.0将导致项目冲突.
作为参考,这就是我的app/build.gradle文件现在的样子:
apply plugin: "com.android.application"
apply plugin: "com.neenbedankt.android-apt"
android {
...
}
dependencies {
...
// Google Cloud Messaging
compile "com.google.android.gms:play-services-gcm:9.2.0"
...
}
apply plugin: "com.google.gms.google-services"
Run Code Online (Sandbox Code Playgroud) 我在我的应用中使用Google通知,直到现在我在清单中完成了以下操作:
<!-- GCM -->
<uses-permission android:name="android.permission.GET_ACCOUNTS" /> <!-- GCM requires a Google account. -->
<uses-permission android:name="android.permission.WAKE_LOCK" /> <!-- Keeps the processor from sleeping when a message is received. -->
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" /> <!-- This app has permission to register and receive data message. -->
<!-- Creates a custom permission so only this app can receive its messages. NOTE: APP_PACKAGE.permission.C2D_MESSAGE -->
<permission android:name="com.myapp.permission.C2D_MESSAGE" android:protectionLevel="signature" />
<uses-permission android:name="com.myapp.permission.C2D_MESSAGE" />
<!-- END GCM -->
Run Code Online (Sandbox Code Playgroud)
它完美运行,直到我将Nexus 7更新为Android 5.0.
现在,当我尝试使用Eclipse在此设备中安装应用程序时,出现此错误:
INSTALL_FAILED_DUPLICATE_PERMISSION perm = com.myapp.permission.C2D_MESSAGE pkg …
android android-notifications google-cloud-messaging android-5.0-lollipop
我过去几个小时一直在阅读关于Push Notification API和Web Notification API的内容.我还发现Google和Apple分别通过GCM和APNS免费提供推送通知服务.
我试图了解我们是否可以使用桌面通知向浏览器实施推送通知,我相信这是Web Notification API所做的.我在这里和这里看到了关于如何为Chrome做这件事的谷歌文档.
现在仍然无法理解的是:
我相信在一个答案中回答的所有问题都可以帮助很多有类似困惑的人.
javascript web-notifications google-cloud-messaging web-push push-api
我试图弄清楚新版本的GCM或Firebase云消息传递是如何工作的,所以我将我的一个项目移动到新的Firebase控制台,如果我没有API KEY或者我想创建一个新的...其中我可以做吗?
Firebase允许我们通过提出POST请求通过我们自己的应用程序发送通知消息.
本教程向我们提供了如何发出此请求的说明.但是,Authorization标题中有字段,我必须放置自己的服务器密钥.
我可以在哪里获得此服务器密钥?没有这方面的说明.
我致力于将Google Analytics和GCM服务添加到我当前的应用中.在两个服务实施指南中,谷歌要求开发人员生成一个json文件:google-services.json并将其放在应用程序的根目录下.
我发现即使我从我的应用程序中删除了这个json文件,服务仍然有效.
只是想知道这个文件到底是什么?它的用途和工作原理是什么?
android json google-analytics google-cloud-messaging google-play-services
我正在我的应用程序中实现Google Cloud Messaging.服务器代码还没有准备好,在我的环境中由于一些防火墙限制,我无法为推送通知部署测试服务器.我正在寻找的是一个在线服务器,它会向我的设备发送一些测试通知来测试我的客户端实现.
android server-push push-notification android-notifications google-cloud-messaging
android ×6
firebase ×2
build.gradle ×1
gradle ×1
javascript ×1
json ×1
php ×1
push-api ×1
server-push ×1
web-push ×1