繁体   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