5

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
4

4 に答える 4

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" />
于 2012-09-11T08:28:10.203 に答える
0

次の手順に従ってください

1.アプリケーションのライブラリに「gcm.jar」を含めます

2. Android SDK Manager => Extras => Google Cloud Messaging for Android Library をインストール (廃止)

3. Android SDK Manager => Android 4.3 (API 18) => Google API のインストール

于 2014-03-31T09:38:44.490 に答える
0

これをマニフェストに入れます

<permission
        android:name="com.example.push.permission.C2D_MESSAGE"
        android:protectionLevel="signature" />
<uses-permission android:name="com.example.push.permission.C2D_MESSAGE" />
于 2012-09-11T08:26:48.663 に答える