onReceives() causes java.lang.IllegalStateException ?
See original GitHub issueHi,
it seems that the version 3.1 is the origin of ANRs and crashes of our Android application in production. I haven’t reproduce it locally yet but the Google Play console reports:
ANR:
Broadcast of Intent { act=android.intent.action.LOCKED_BOOT_COMPLETED flg=0x9000010 cmp=de.spotlight.wordoftheday.deutsch/com.telerik.localnotifications.NotificationRestoreReceiver (has extras) }
Exceptions (mainly on Android 9):
java.lang.RuntimeException:
at android.app.ActivityThread.handleReceiver (ActivityThread.java:3606)
at android.app.ActivityThread.access$1300 (ActivityThread.java:237)
at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1796)
at android.os.Handler.dispatchMessage (Handler.java:106)
at android.os.Looper.loop (Looper.java:214)
at android.app.ActivityThread.main (ActivityThread.java:7045)
at java.lang.reflect.Method.invoke (Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:965)
Caused by: java.lang.IllegalStateException:
at android.app.ContextImpl.getSharedPreferences (ContextImpl.java:467)
at android.app.ContextImpl.getSharedPreferences (ContextImpl.java:441)
at android.content.ContextWrapper.getSharedPreferences (ContextWrapper.java:179)
at android.content.ContextWrapper.getSharedPreferences (ContextWrapper.java:179)
at com.telerik.localnotifications.Store.getAll (Store.java:34)
at com.telerik.localnotifications.NotificationRestoreReceiver.onReceive (NotificationRestoreReceiver.java:27)
at android.app.ActivityThread.handleReceiver (ActivityThread.java:3597)
Exceptions (mainly on Android 5.x, 6.x, 7.x., 8.x):
android.app.RemoteServiceException:
at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1906)
at android.os.Handler.dispatchMessage (Handler.java:106)
at android.os.Looper.loop (Looper.java:164)
at android.app.ActivityThread.main (ActivityThread.java:7000)
at java.lang.reflect.Method.invoke (Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:441)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1408)
For the exceptions in Android 9 the error comes likely from the method onReceive() in https://github.com/EddyVerbruggen/nativescript-local-notifications/blob/45221c199b4b0efd09d0c2849e7a4d26bf8dc42f/native-src/android/app/src/main/java/com/telerik/localnotifications/NotificationRestoreReceiver.java
In the method onReceive() shouldn’t a test be added before the method’s body:
if (intent.getAction().equalsIgnoreCase(Intent.ACTION_BOOT_COMPLETED)) {
if (context != null) {
// the previous code here
}
I don’t really understand the ins and outs of this part but it seems that it was the solution for:
Issue Analytics
- State:
- Created 4 years ago
- Comments:12 (5 by maintainers)
Top GitHub Comments
Give 3.2.2 a go.
@EddyVerbruggen Can we re-open this until the fix is out please? 😃