0

GoogleCloudMessagingをアプリケーションに統合しようとしています。onCreateメソッドに次のコードがあります。

    GCMRegistrar.checkDevice(this);
    GCMRegistrar.checkManifest(this);
    if (GCMRegistrar.getRegistrationId(this).equals(""))
        GCMRegistrar.register(this, "xxxxxxxxxxxx");

GCMRegistararを適切にインポートし、GCM.jarをビルドパスに追加して、マニフェストを設定しました。2.2 droid 1にインストールしています。アプリケーションが起動するたびに、次のクラッシュが発生します。

ここに画像の説明を入力してください

私のマニフェストは次のとおりです

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.my.project"
android:versionCode="1"
android:versionName="1.0" >

<uses-permission android:name="android.permission.INTERNET" />

<uses-sdk
    android:minSdkVersion="8"
    android:targetSdkVersion="8" />

<permission
    android:name="com.my.project.permission.C2D_MESSAGE"
    android:protectionLevel="signature" />

<uses-permission android:name="com.my.project.permission.C2D_MESSAGE" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<application
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name" >
    <receiver
        android:name="com.google.android.gcm.GCMBroadcastReceiver"
        android:permission="com.google.android.c2dm.permission.SEND" >
        <intent-filter>
            <action android:name="com.google.android.c2dm.intent.RECEIVE" />
            <action android:name="com.google.android.c2dm.intent.REGISTRATION" />

            <category android:name="com.my.project" />
        </intent-filter>
    </receiver>

    <service android:name=".GCMIntentService" />

    <activity
        android:name=".Index"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>

4

1 に答える 1

2

gcm.jar を libs フォルダーにコピーし、その gcm.jar をビルド パスに参照することになりました。それは今働いています。

于 2012-07-14T03:05:40.110 に答える