简体   繁体   English

同时使用pushwoosh和gcm库时出错

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

I have used GCM to send single message to user. 我已经使用GCM向用户发送单个消息。 It's working fine but when I used pushwoosh to send messages to all registered device then I am getting an error and the error is 它工作正常,但是当我使用pushwoosh将消息发送到所有已注册的设备时,出现了错误,错误是

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

so I removed GCM.jar file because in PushWoosh they already provide GCMIntentService class but I got another error in GCMIntentService.java file as I shown below 所以我删除了GCM.jar文件,因为在PushWoosh中它们已经提供了GCMIntentService类,但是我在GCMIntentService.java文件中遇到了另一个错误,如下所示

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

Here I am getting suggestion to remove arguments to match GCMIntentService and constructor is undefined. 在这里,我得到建议删除参数以匹配GCMIntentService,并且构造函数未定义。 Suggestion is below 建议如下

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

If I remove Config.GOOGLE_SENDER_ID how can we set sender id. 如果我删除Config.GOOGLE_SENDER_ID,我们如何设置发件人ID。

This constructor for GCMBaseIntentSerice is context specific. GCMBaseIntentSerice的此构造方法是特定于上下文的。 Constructor that does not set a sender id, useful when the sender id is context-specific. 不设置发送者ID的构造方法,当发送者ID是特定于上下文时有用。 When using this constructor, the subclass must override getSenderIds(Context), otherwise methods such as onHandleIntent(Intent) will throw an IllegalStateException on runtime. 使用此构造方法时,子类必须重写getSenderIds(Context),否则诸如onHandleIntent(Intent)之类的方法将在运行时引发IllegalStateException。 Check the official documention http://developer.android.com/reference/com/google/android/gcm/GCMBaseIntentService.html#GCMBaseIntentService() 检查官方文档http://developer.android.com/reference/com/google/android/gcm/GCMBaseIntentService.html#GCMBaseIntentService()

After overriding the method you can set sender ids there. 覆盖该方法后,您可以在此处设置发件人ID。 See the code below. 请参见下面的代码。

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

With Pushwoosh you don't need to go that deep with GCMIntentService. 使用Pushwoosh,您无需深入了解GCMIntentService。 Just put the Project ID into AndroidManifest.xml under applications tag: 只需将Project ID放入应用程序标签下的AndroidManifest.xml中即可:

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

See the step 4 here: http://www.pushwoosh.com/programming-push-notification/android/native-android-sdk-integration/ 请参阅此处的步骤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