簡體   English   中英

同時使用pushwoosh和gcm庫時出錯

[英]Getting error while using pushwoosh and gcm library both

我已經使用GCM向用戶發送單個消息。 它工作正常,但是當我使用pushwoosh將消息發送到所有已注冊的設備時,出現了錯誤,錯誤是

Conversion to Dalvik format failed: Unable to execute dex: Multiple dex files define Lcom/google/android/gcm/GCMBaseIntentService'

所以我刪除了GCM.jar文件,因為在PushWoosh中它們已經提供了GCMIntentService類,但是我在GCMIntentService.java文件中遇到了另一個錯誤,如下所示

http://www.imagesup.net/?di=1414011958054

在這里,我得到建議刪除參數以匹配GCMIntentService,並且構造函數未定義。 建議如下

public GCMIntentService() {
    // Call extended class Constructor GCMBaseIntentService
    super();
}

如果我刪除Config.GOOGLE_SENDER_ID,我們如何設置發件人ID。

GCMBaseIntentSerice的此構造方法是特定於上下文的。 不設置發送者ID的構造方法,當發送者ID是特定於上下文時有用。 使用此構造方法時,子類必須重寫getSenderIds(Context),否則諸如onHandleIntent(Intent)之類的方法將在運行時引發IllegalStateException。 檢查官方文檔http://developer.android.com/reference/com/google/android/gcm/GCMBaseIntentService.html#GCMBaseIntentService()

覆蓋該方法后,您可以在此處設置發件人ID。 請參見下面的代碼。

@Override
 protected String[] getSenderIds(Context context) {
     String[] ids = new String[1];
     ids[0] = Config.GOOGLE_SENDER_ID;
     return ids;
  }

使用Pushwoosh,您無需深入了解GCMIntentService。 只需將Project ID放入應用程序標簽下的AndroidManifest.xml中即可:

<meta-data android:name="PW_APPID" android:value="4F0C807E51EC77.93591449" /> <meta-data android:name="PW_PROJECT_ID" android:value="A60756016005" />

請參閱此處的步驟4: http : //www.pushwoosh.com/programming-push-notification/android/native-android-sdk-integration/

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM