question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

onReceives() causes java.lang.IllegalStateException ?

See original GitHub issue

Hi,

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:closed
  • Created 4 years ago
  • Comments:12 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
EddyVerbruggencommented, Jun 13, 2019

Give 3.2.2 a go.

1reaction
shiv19commented, Jun 13, 2019

@EddyVerbruggen Can we re-open this until the fix is out please? 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Caused by: java.lang.IllegalStateException: - Stack Overflow
The documetation indicates the IllegalStateException is thrown when: If the application is in a state where the service can not be started ...
Read more >
Crash - java.lang.IllegalStateException - BR.onReceive - B4X
I have a crash report in google play console. My targetsdkversion is 26 and B4A version is 8.5. Samsung Galaxy On7 Prime (on7xreflte), ......
Read more >
3 ways to solve java.lang.NoClassDefFoundError in Java J2EE
I know how frustrating is to see Exception in thread "main" java.lang.NoClassDefFoundError, which is a manifestation of NoClassDefFoundError in Java.
Read more >
BroadcastReceiver | Android Developers
Causes the current thread to wait until another thread invokes the notify() method or the notifyAll() method for this object, or some other...
Read more >
[geomesa-users] Spark lost task java.lang.IllegalStateException
I am getting Lost task 1.0 in stage 0.0 (TID 1, 147.175.3.163): java.lang.IllegalStateException: unread block data error when trying to compile and run ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found