我尝试实施GCM,但是我收到错误,我试图找到日志互联网,但我不能。 代码来到这些行时,我在logcat
时遇到错误GCMRegistrar.checkDevice(this);
GCMRegistrar.checkManifest(this);
这个logcat输出是什么意思?
09-11 11:14:25.132: W/dalvikvm(11946): threadid=11: thread exiting with uncaught exception (group=0x40aac210)
09-11 11:14:25.142: E/AndroidRuntime(11946): FATAL EXCEPTION: IntentService[ManagePushCommunicationService]
09-11 11:14:25.142: E/AndroidRuntime(11946): java.lang.IllegalStateException: Application does not define permission com.example.push.permission.C2D_MESSAGE
09-11 11:14:25.142: E/AndroidRuntime(11946): at com.google.android.gcm.GCMRegistrar.checkManifest(GCMRegistrar.java:135)
09-11 11:14:25.142: E/AndroidRuntime(11946): at com.example.push.services.ManagePushCommunicationService.startJob(ManagePushCommunicationService.java:156)
09-11 11:14:25.142: E/AndroidRuntime(11946): at com.example.push.services.ManagePushCommunicationService.onHandleIntent(ManagePushCommunicationService.java:85)
09-11 11:14:25.142: E/AndroidRuntime(11946): at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65)
09-11 11:14:25.142: E/AndroidRuntime(11946): at android.os.Handler.dispatchMessage(Handler.java:99)
09-11 11:14:25.142: E/AndroidRuntime(11946): at android.os.Looper.loop(Looper.java:137)
09-11 11:14:25.142: E/AndroidRuntime(11946): at android.os.HandlerThread.run(HandlerThread.java:60)
09-11 11:19:25.162: I/Process(11946): Sending signal. PID: 11946 SIG: 9
答案 0 :(得分:5)
在清单文件中放置权限:
<permission android:name="com.example.gcm.permission.C2D_MESSAGE"android:protectionLevel="signature"/>
<uses-permission android:name="com.example.gcm.permission.C2D_MESSAGE" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
答案 1 :(得分:0)
把它放在你的清单
中<permission
android:name="com.example.push.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="com.example.push.permission.C2D_MESSAGE" />
答案 2 :(得分:0)
Plz遵循以下步骤
1。包括&#34; gcm.jar&#34;在您的应用程序的库中
2. Android SDK Manager =&gt;额外=&gt;安装适用于Android库的Google Cloud Messaging(已过时)
3. Android SDK Manager =&gt; Android 4.3(API 18)=&gt;安装Google API
答案 3 :(得分:0)
授予
许可<permission android:name="your package name.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="your package name.permission.C2D_MESSAGE" />