Unable to start service com.huawei.hms.rn.push.remote.HmsPushMessageService

780 views Asked by At

When receiving data message from server, this error log is display:

E/AndroidRuntime: FATAL EXCEPTION: main Process: com.sample.test, PID: 30964 java.lang.RuntimeException: Unable to start service com.huawei.hms.rn.push.remote.HmsPushMessageService@d69f855 with Intent { act=com.huawei.push.action.MESSAGING_EVENT pkg=com.sample.test (has extras) }: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.content.Context.getPackageName()' on a null object reference at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:4683) at android.app.ActivityThread.access$2900(ActivityThread.java:296) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2259) at android.os.Handler.dispatchMessage(Handler.java:107) at android.os.Looper.loop(Looper.java:213) at android.app.ActivityThread.main(ActivityThread.java:8178) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:513) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1101) Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.content.Context.getPackageName()' on a null object reference at com.huawei.hms.rn.push.logger.HMSLogger.setupEventMap(HMSLogger.java:292) at com.huawei.hms.rn.push.logger.HMSLogger.(HMSLogger.java:78) at com.huawei.hms.rn.push.logger.HMSLogger.getInstance(HMSLogger.java:95) at com.huawei.hms.rn.push.remote.HmsPushMessageService.onMessageReceived(HmsPushMessageService.java:35) at com.huawei.hms.push.HmsMessageService.a(HmsMessageService.java:185) at com.huawei.hms.push.HmsMessageService.onStartCommand(HmsMessageService.java:131) at com.huawei.hms.rn.push.remote.HmsPushMessageService.onStartCommand(HmsPushMessageService.java:90) at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:4663) at android.app.ActivityThread.access$2900(ActivityThread.java:296)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2259)  at android.os.Handler.dispatchMessage(Handler.java:107)  at android.os.Looper.loop(Looper.java:213)  at android.app.ActivityThread.main(ActivityThread.java:8178)  at java.lang.reflect.Method.invoke(Native Method)  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:513)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1101)

3

There are 3 answers

1
MobileDev On

It seems your are using data messages, if yes tell me how you get data from notification? EX: In this code we are receiving "id" data message which we post from console or server:

   override fun onMessageReceived(message: RemoteMessage?) {
    Log.i("OnMesageReceived", "onMessageReceived is called");

    //data notification -get data
    val id = message!!.dataOfMap["id"]

}

1
Walter Devia On

Version 5.0.2.301 solved my issue working with react-native@^0.63.4. But it doesn't work with the latest version of the plugin available today (5.1.1-301).

@shirley FYI

0
zhangxaochen On

This problem is a known bug and it has been rectified already. Please update React Native Push Plugin to the latest version 5.0.2.301 here.