可能重复:
android GCM 不起作用
使用 GCM 演示项目,我设法注册了一些设备(在网站上,在 Tomcat 服务器中运行,我可以看到它们列出)但是当我单击“发送消息”按钮时,客户端没有任何反应,没有收到任何消息。
Tomcat 日志显示:
0:0:0:0:0:0:0:1 - - [11/Jul/2012:11:10:57 +0200] "GET / HTTP/1.1" 200 11444
0:0:0:0:0:0:0:1 - - [11/Jul/2012:11:10:57 +0200] "GET /tomcat.css HTTP/1.1" 200 5926
0:0:0:0:0:0:0:1 - - [11/Jul/2012:11:10:57 +0200] "GET /tomcat.png HTTP/1.1" 200 5103
0:0:0:0:0:0:0:1 - - [11/Jul/2012:11:10:57 +0200] "GET /bg-upper.png HTTP/1.1" 200 3103
0:0:0:0:0:0:0:1 - - [11/Jul/2012:11:10:57 +0200] "GET /bg-nav.png HTTP/1.1" 200 1401
0:0:0:0:0:0:0:1 - - [11/Jul/2012:11:10:57 +0200] "GET /asf-logo.png HTTP/1.1" 200 17811
0:0:0:0:0:0:0:1 - - [11/Jul/2012:11:10:57 +0200] "GET /bg-middle.png HTTP/1.1" 200 1918
0:0:0:0:0:0:0:1 - - [11/Jul/2012:11:10:57 +0200] "GET /bg-button.png HTTP/1.1" 200 713
0:0:0:0:0:0:0:1 - - [11/Jul/2012:11:10:57 +0200] "GET /favicon.ico HTTP/1.1" 200 21630
0:0:0:0:0:0:0:1 - - [11/Jul/2012:11:11:06 +0200] "GET /gcm HTTP/1.1" 404 974
0:0:0:0:0:0:0:1 - - [11/Jul/2012:11:11:30 +0200] "GET /gcm-demo HTTP/1.1" 302 -
0:0:0:0:0:0:0:1 - - [11/Jul/2012:11:11:30 +0200] "GET /gcm-demo/ HTTP/1.1" 200 134
0:0:0:0:0:0:0:1 - - [11/Jul/2012:11:11:30 +0200] "GET /gcm-demo/favicon.png HTTP/1.1" 200 949
172.20.5.53 - - [11/Jul/2012:11:14:27 +0200] "POST /gcm-demo/register HTTP/1.1" 200 -
172.20.5.53 - - [11/Jul/2012:11:14:27 +0200] "POST /gcm-demo/register HTTP/1.1" 200 -
0:0:0:0:0:0:0:1 - - [11/Jul/2012:11:14:43 +0200] "GET /gcm-demo/ HTTP/1.1" 200 235
0:0:0:0:0:0:0:1 - - [11/Jul/2012:11:14:52 +0200] "POST /gcm-demo/sendAll HTTP/1.1" 200 319
0:0:0:0:0:0:0:1 - - [11/Jul/2012:11:15:09 +0200] "POST /gcm-demo/sendAll HTTP/1.1" 200 319
0:0:0:0:0:0:0:1 - - [11/Jul/2012:11:15:33 +0200] "POST /gcm-demo/sendAll HTTP/1.1" 200 319
0:0:0:0:0:0:0:1 - - [11/Jul/2012:11:15:41 +0200] "POST /gcm-demo/sendAll HTTP/1.1" 200 319
0:0:0:0:0:0:0:1 - - [11/Jul/2012:11:23:35 +0200] "POST /gcm-demo/sendAll HTTP/1.1" 200 319
0:0:0:0:0:0:0:1 - - [11/Jul/2012:11:23:56 +0200] "POST /gcm-demo/sendAll HTTP/1.1" 200 319
172.20.5.53 - - [11/Jul/2012:11:28:21 +0200] "POST /gcm-demo/register HTTP/1.1" 200 -
172.20.5.53 - - [11/Jul/2012:11:28:21 +0200] "POST /gcm-demo/register HTTP/1.1" 200 -
0:0:0:0:0:0:0:1 - - [11/Jul/2012:11:28:51 +0200] "POST /gcm-demo/sendAll HTTP/1.1" 200 403
0:0:0:0:0:0:0:1 - - [11/Jul/2012:11:29:02 +0200] "POST /gcm-demo/sendAll HTTP/1.1" 200 403
0:0:0:0:0:0:0:1 - - [11/Jul/2012:11:56:09 +0200] "POST /gcm-demo/sendAll HTTP/1.1" 200 403
0:0:0:0:0:0:0:1 - - [11/Jul/2012:12:12:21 +0200] "POST /gcm-demo/sendAll HTTP/1.1" 200 403
0:0:0:0:0:0:0:1 - - [11/Jul/2012:12:37:13 +0200] "POST /gcm-demo/sendAll HTTP/1.1" 200 403
有什么线索吗?这是我的清单:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.google.android.gcm.demo.app"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="16"/>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<permission
android:name="com.google.android.gcm.demo.app.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission
android:name="com.google.android.gcm.demo.app.permission.C2D_MESSAGE" />
<uses-permission
android:name="com.google.android.c2dm.permission.RECEIVE" />
<!-- Main activity. -->
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:name="com.google.android.gcm.demo.app.DemoActivity"
android:label="@string/app_name"
android:screenOrientation="portrait" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<receiver
android:name="com.google.android.gcm.GCMBroadcastReceiver"
android:permission="com.google.android.c2dm.permission.SEND" >
<intent-filter>
<!-- Receives the actual messages. -->
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<!-- Receives the registration id. -->
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<category android:name="com.google.android.gcm.demo.app" />
</intent-filter>
</receiver>
<service android:name=".GCMIntentService" />
</application>
</manifest>
我在 11 sdk 版本的设备上进行测试。
提前致谢。