2012-07-12 59 views
0

我在嘗試將Google Cloud Messaging集成到我的應用程序中。 我在我的onCreate方法中有以下代碼。檢查設備/清單時出現GCM NoClassDefFoundError

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

我有GCMRegistarar正確導入,我有GCM.jar添加到構建路徑和我的清單設置。我正在安裝到2.2 droid 1.每當應用程序啓動時,我得到以下崩潰。

enter image description here

我的清單是如下

<?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> 

+0

Play商店是否爲測試設備上的最新版本? – 2012-07-12 16:46:56

+0

是的,我最終將gcm.jar複製到libs文件夾中,然後將gcm.jar引用到我的構建路徑。現在正在工作。 – endy 2012-07-12 16:49:10

+0

你可以自己回答。所以人們會知道這個問題已經得到解答。 – 2012-07-13 21:13:54

回答

2

我結束了複製gcm.jar到libs文件夾,然後引用該gcm.jar到我的構建路徑。現在正在工作。