简体   繁体   English

连接断开后,Google Cloud消息注册,然后应用崩溃

[英]Google Cloud message register when lost connection then the app crash

I am using GCM plugin for Unity. 我正在为Unity使用GCM插件。 I register it with dynamic senderIDs. 我用动态senderID注册了它。 But if i lost connection while registering, the app crashes. 但是,如果我在注册时失去连接,该应用程序将崩溃。

The error log is : 错误日志为:

W/System.err( 4993): java.lang.IllegalStateException: sender id not set on constructor
W/System.err( 4993):    at com.google.android.gcm.GCMBaseIntentService.getSenderIds(GCMBaseIntentService.java:125)
W/System.err( 4993):    at com.google.android.gcm.GCMBaseIntentService.onHandleIntent(GCMBaseIntentService.java:237)
W/System.err( 4993):    at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65)
W/System.err( 4993):    at android.os.Handler.dispatchMessage(Handler.java:102)
W/System.err( 4993):    at android.os.Looper.loop(Looper.java:145)
W/System.err( 4993):    at android.os.HandlerThread.run(HandlerThread.java:61)
E/AndroidRuntime( 4993): FATAL EXCEPTION: IntentService[GCMIntentService-DynamicSenderIds-2]
E/AndroidRuntime( 4993): Process: ba.lum.tribalrivals.arabic, PID: 4993
E/AndroidRuntime( 4993): java.lang.Error: FATAL EXCEPTION [IntentService[GCMIntentService-DynamicSenderIds-2]]
E/AndroidRuntime( 4993): Unity version     : 4.6.7f1
E/AndroidRuntime( 4993): Device model      : samsung SM-N910C
E/AndroidRuntime( 4993): Device fingerprint: samsung/treltexx/trelte:5.0.1/LRX22C/N910CXXU1BOE1:user/release-keys
E/AndroidRuntime( 4993): 
E/AndroidRuntime( 4993): Caused by: java.lang.IllegalStateException: sender id not set on constructor
E/AndroidRuntime( 4993):    at com.google.android.gcm.GCMBaseIntentService.getSenderIds(GCMBaseIntentService.java:125)
E/AndroidRuntime( 4993):    at com.google.android.gcm.GCMBaseIntentService.onHandleIntent(GCMBaseIntentService.java:237)
E/AndroidRuntime( 4993):    at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65)
E/AndroidRuntime( 4993):    at android.os.Handler.dispatchMessage(Handler.java:102)
E/AndroidRuntime( 4993):    at android.os.Looper.loop(Looper.java:145)
E/AndroidRuntime( 4993):    at android.os.HandlerThread.run(HandlerThread.java:61)

I found out that the reason is from this code inside gcm.jar (plugin library): 我发现原因是来自gcm.jar(插件库)中的以下代码:

protected String[] getSenderIds(Context context)
  {
    if (this.mSenderIds == null) {
      throw new IllegalStateException("sender id not set on constructor");
    }
    return this.mSenderIds;
  }

Can anyone know how to fix this problem ? 谁能解决这个问题? Should i change the code inside plugin ? 我应该更改插件中的代码吗? And how do i do that ? 我该怎么办呢?

Not familiar with the GCM plugin for Unity. 不熟悉Unity的GCM插件。 However, this clearly indicates that your app cannot find the sender ID (project number) of the project that you created on the Google developers console. 但是,这显然表明您的应用程序找不到您在Google开发人员控制台上创建的项目的发件人ID(项目编号)。 Find that, and add it to the mSenderIds array. 找到它,并将其添加到mSenderIds数组。 It looks like you can do so in the constructor when you create an instance of that class. 看起来当您创建该类的实例时,可以在构造函数中这样做。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM