React-native-push-notification: Illegal State Exception in Production for Android 8.0 using latest master commit

Created on 24 Jul 2018  路  13Comments  路  Source: zo0r/react-native-push-notification

Hello!

We're testing out 3.1.1 which doesn't seem to be on NPM just yet. We seem to be getting crashes on version 8.0+ of android in production related to the requestPermission call of the react-native-push-notification's library.

I've attached a screenshot of the crash.

screen shot 2018-07-23 at 6 31 45 pm

Stale To test bug

Most helpful comment

(Issue #803) #809 doesn't seems to solve the problem. It prevented the crash. But I don't think notification are received for 8.0+

we need to have implementation like @diegolmello

All 13 comments

I've a similar issue with Oreo.
Running version 3.1.1 on RN 0.56.

07-24 17:52:01.010 4130-4160/? E/unknown:ReactNative: Exception in native call java.lang.IllegalStateException: Not allowed to start service Intent { cmp=chat.rocket.reactnative.debug/com.dieam.reactnativepushnotification.modules.RNPushNotificationRegistrationService (has extras) }: app is in background uid UidRecord{b647c53 u0a86 TRNB idle procs:1 seq(0,0,0)} at android.app.ContextImpl.startServiceCommon(ContextImpl.java:1505) at android.app.ContextImpl.startService(ContextImpl.java:1461) at android.content.ContextWrapper.startService(ContextWrapper.java:644) at android.content.ContextWrapper.startService(ContextWrapper.java:644) at com.dieam.reactnativepushnotification.modules.RNPushNotification.requestPermissions(RNPushNotification.java:115) at java.lang.reflect.Method.invoke(Native Method) at com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:372) at com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:160) at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method) at android.os.Handler.handleCallback(Handler.java:789) at android.os.Handler.dispatchMessage(Handler.java:98) at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:29) at android.os.Looper.loop(Looper.java:164) at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:192) at java.lang.Thread.run(Thread.java:764)

put a try catch works for me!
try {
GCMService.putExtra("senderID", senderID);
reactContext.startService(GCMService);
} catch (Exception e) {
Log.d("EXCEPTION SERVICE::::::", "requestPermissions: " + e);
}

in -->
node_modules/react-native-push-notification/android/src/main/java/com/dieam/reactnativepushnotification/modules/RNPushNotification.java:115

I opened a PR at wix/react-native-notifications about this.
https://github.com/wix/react-native-notifications/pull/244

Something similar should fix this lib as well.

Can someone test the patch from @diegolmello ? We can merge after that.

(Issue #803) #809 doesn't seems to solve the problem. It prevented the crash. But I don't think notification are received for 8.0+

we need to have implementation like @diegolmello

How can we make this work, having the same problem.

Hi all, any news when this fix would be released? thanks!

Same here this is a problem on android 8.

Hi guys,

it seems the issue disappeared after I put

<meta-data android:name="com.dieam.reactnativepushnotification.notification_channel_name" android:value="YOUR NOTIFICATION CHANNEL NAME"/> <meta-data android:name="com.dieam.reactnativepushnotification.notification_channel_description" android:value="YOUR NOTIFICATION CHANNEL DESCRIPTION"/>

into manifest.xml.

Tested just on Android 8.

@zabkwak no it doesn't, mine error log is:

11-02 03:48:27.211  2614  2662 E com.marianhello.logging.UncaughtExceptionLogger: FATAL EXCEPTION: IntentService[RNPushNotification]java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/common/util/zzx;
11-02 03:48:27.211  2614  2662 E com.marianhello.logging.UncaughtExceptionLogger:   at com.dieam.reactnativepushnotification.modules.RNPushNotificationRegistrationService.onHandleIntent(RNPushNotificationRegistrationService.java:24)
11-02 03:48:27.217  2614  2662 E AndroidRuntime: FATAL EXCEPTION: IntentService[RNPushNotification]
11-02 03:48:27.217  2614  2662 E AndroidRuntime:    at com.dieam.reactnativepushnotification.modules.RNPushNotificationRegistrationService.onHandleIntent(RNPushNotificationRegistrationService.java:24)

@martingalovic is it related to this issue?
I can't be sure but it seems you're missing some dependencies according to java.lang.NoClassDefFoundError.

@zabkwak already solved it in #910

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 30 days if no further activity occurs. Thank you for your contributions.

Was this page helpful?
0 / 5 - 0 ratings