# IllegalStateException Crashes

**URL:** <https://forums.solar2d.com/t/illegalstateexception-crashes/348854>\
**Category:** Android\
**Created:** [November 5, 2018, 6:28am UTC](https://forums.solar2d.com/t/illegalstateexception-crashes/348854 "2018-11-05T06:28:53Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![beernathan](https://forums.solar2d.com/letter_avatar_proxy/v4/letter/b/838e76/32.png) [@beernathan](https://forums.solar2d.com/u/beernathan)\
**Post date:** [November 5, 2018, 6:28am UTC](https://forums.solar2d.com/t/illegalstateexception-crashes/348854/1 "2018-11-05T06:28:53Z")

</div>

Hi,

After releasing recently based on Corona 3326 we’re getting a LOT of Android crashes on Android 8 (and a few on 8.1). Google Play is reporting it to us as:

**java.lang.RuntimeException** :

&nbsp;

at android.app.ActivityThread.handleReceiver (ActivityThread.java:3397)

&nbsp;

at android.app.ActivityThread.-wrap18 (Unknown Source)

&nbsp;

at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1780)

&nbsp;

at android.os.Handler.dispatchMessage (Handler.java:105)

&nbsp;

at android.os.Looper.loop (Looper.java:164)

&nbsp;

at android.app.ActivityThread.main (ActivityThread.java:6938)

&nbsp;

at java.lang.reflect.Method.invoke (Native Method)

&nbsp;

at com.android.internal.os.Zygote$MethodAndArgsCaller.run (Zygote.java:327)

&nbsp;

at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1374)

Caused by: **java.lang.IllegalStateException** :

&nbsp;

at android.app.ContextImpl.startServiceCommon (ContextImpl.java:1538)

&nbsp;

at android.app.ContextImpl.startService (ContextImpl.java:1484)

&nbsp;

at android.content.ContextWrapper.startService (ContextWrapper.java:663)

&nbsp;

at android.content.ContextWrapper.startService (ContextWrapper.java:663)

&nbsp;

at com.ansca.corona.SystemStartupBroadcastReceiver.onReceive (SystemStartupBroadcastReceiver.java:29)

&nbsp;

at android.app.ActivityThread.handleReceiver (ActivityThread.java:3390)

Anyone else getting this? Any ideas?

Thanks,

Nathan.

---

<div class="post-metadata">

**Author:** ![rob](https://forums.solar2d.com/user_avatar/forums.solar2d.com/rob/32/4_2.png) [@rob](https://forums.solar2d.com/u/rob)\
**Post date:** [November 5, 2018, 7:27pm UTC](https://forums.solar2d.com/t/illegalstateexception-crashes/348854/2 "2018-11-05T19:27:46Z")

</div>

What plugins are you using?

Rob

---

<div class="post-metadata">

**Author:** ![beernathan](https://forums.solar2d.com/letter_avatar_proxy/v4/letter/b/838e76/32.png) [@beernathan](https://forums.solar2d.com/u/beernathan)\
**Post date:** [November 5, 2018, 9:44pm UTC](https://forums.solar2d.com/t/illegalstateexception-crashes/348854/3 "2018-11-05T21:44:00Z")

</div>

gameanalytics

OneSignal

advertisingId

native.popup.social

notifications

googleAnalytics

analytics.flurry

gaemNetwork.google

CoronaSplashControl

OK, so the analytics are a bit over the top - could drop Flurry & GA, but have had them there forever and it hasn’t been a problem before.

Nathan.

---

<div class="post-metadata">

**Author:** ![beernathan](https://forums.solar2d.com/letter_avatar_proxy/v4/letter/b/838e76/32.png) [@beernathan](https://forums.solar2d.com/u/beernathan)\
**Post date:** [November 6, 2018, 10:40pm UTC](https://forums.solar2d.com/t/illegalstateexception-crashes/348854/4 "2018-11-06T22:40:03Z")

</div>

Any ideas @robmiracle ?

---

<div class="post-metadata">

**Author:** ![rob](https://forums.solar2d.com/user_avatar/forums.solar2d.com/rob/32/4_2.png) [@rob](https://forums.solar2d.com/u/rob)\
**Post date:** [November 6, 2018, 11:49pm UTC](https://forums.solar2d.com/t/illegalstateexception-crashes/348854/5 "2018-11-06T23:49:23Z")

</div>

What is this plugin:&nbsp;gaemNetwork.google?

Is there a more detailed stack trace on the crashes?&nbsp; (please use [pastebin.com](http://pastebin.com) or similar to share them)

Rob

---

<div class="post-metadata">

**Author:** ![beernathan](https://forums.solar2d.com/letter_avatar_proxy/v4/letter/b/838e76/32.png) [@beernathan](https://forums.solar2d.com/u/beernathan)\
**Post date:** [November 7, 2018, 12:41am UTC](https://forums.solar2d.com/t/illegalstateexception-crashes/348854/6 "2018-11-07T00:41:00Z")

</div>

Hi @robmiracle it’s this one (I just spelt it wrong above)…

[https://docs.coronalabs.com/plugin/gameNetwork-google/index.html](https://docs.coronalabs.com/plugin/gameNetwork-google/index.html)

Just noticed that it’s legacy and I’m pretty sure we’re not even using it in this app - was a hangover from an existing build.settings file.

That’s all the detail I have - it’s just from the Crash report on the Google Play console.

---

<div class="post-metadata">

**Author:** ![rob](https://forums.solar2d.com/user_avatar/forums.solar2d.com/rob/32/4_2.png) [@rob](https://forums.solar2d.com/u/rob)\
**Post date:** [November 7, 2018, 1:54am UTC](https://forums.solar2d.com/t/illegalstateexception-crashes/348854/7 "2018-11-07T01:54:55Z")

</div>

You certainly should probably avoid using&nbsp;“CoronaProvider.gameNetwork.google”. It was replaced by the GPGS plugin a long time ago and we recently updated it to GPGS v2 to be compliant with current Google requirements. If you’re not using it, I’d remove it. If you’re using it, you should switch to GPGS v2.

There is also a new notifications plugin, notifications&nbsp;v2 that uses Firebase Cloud Messaging (FCM) instead of Google Cloud Messaging (GCM) which is Google’s preferred way to send notifications. Though I don’t know that it should crash you.

As far as the stack trace, the Google Play developer console should let you drill down to see the specific error.&nbsp;

Rob

---

<div class="post-metadata">

**Author:** ![beernathan](https://forums.solar2d.com/letter_avatar_proxy/v4/letter/b/838e76/32.png) [@beernathan](https://forums.solar2d.com/u/beernathan)\
**Post date:** [November 7, 2018, 1:58am UTC](https://forums.solar2d.com/t/illegalstateexception-crashes/348854/8 "2018-11-07T01:58:56Z")

</div>

Looks like we don’t ever require “gameNetwork” in the code, so I doubt that’s it, but I will replace.

Looking at how to get a bigger stack trace from GP.

Update: Google Play only provides what I pasted above

Interestingly we don’t have any user reports of the problem - could be something failing silently?

Why do you think it’s a plugin issue?

---

<div class="post-metadata">

**Author:** ![beernathan](https://forums.solar2d.com/letter_avatar_proxy/v4/letter/b/838e76/32.png) [@beernathan](https://forums.solar2d.com/u/beernathan)\
**Post date:** [November 20, 2018, 8:15am UTC](https://forums.solar2d.com/t/illegalstateexception-crashes/348854/9 "2018-11-20T08:15:38Z")

</div>

Any ideas on this @robmiracle ? We’re now at 8% crash rate on Google Play putting us waaaay over the bad behaviour threshold.

Any ideas?

---

<div class="post-metadata">

**Author:** ![rob](https://forums.solar2d.com/user_avatar/forums.solar2d.com/rob/32/4_2.png) [@rob](https://forums.solar2d.com/u/rob)\
**Post date:** [November 20, 2018, 3:35pm UTC](https://forums.solar2d.com/t/illegalstateexception-crashes/348854/10 "2018-11-20T15:35:09Z")

</div>

I searched the forums for this error and there are threads around OneSignal&nbsp;and Notifications.&nbsp;

I don’t know if you’ve switched from “notifications” to “notifications-v2” yet. I know that changes some backend processes for you. I know OneSignal&nbsp;has recently updated their plugin too. I don’t know how dependent you’re on those two plugins, but you could conduct a test and see if removing one or the other helps out.

Also, there is a thread that shows how to use OneSignal’s REST API instead of the plugin, which may be a long-term more stable approach to using OneSignal.

I have engineering looking at the post to come up with some better ideas.

Rob

---

<div class="post-metadata">

**Author:** ![beernathan](https://forums.solar2d.com/letter_avatar_proxy/v4/letter/b/838e76/32.png) [@beernathan](https://forums.solar2d.com/u/beernathan)\
**Post date:** [November 21, 2018, 8:50am UTC](https://forums.solar2d.com/t/illegalstateexception-crashes/348854/11 "2018-11-21T08:50:37Z")

</div>

Thanks Rob - will look into those two.

---

<div class="post-metadata">

**Author:** ![beernathan](https://forums.solar2d.com/letter_avatar_proxy/v4/letter/b/838e76/32.png) [@beernathan](https://forums.solar2d.com/u/beernathan)\
**Post date:** [November 21, 2018, 8:55am UTC](https://forums.solar2d.com/t/illegalstateexception-crashes/348854/12 "2018-11-21T08:55:26Z")

</div>

Looks like we’re still on legacy notifications as we’re still on&nbsp;Google Cloud Messaging - it says legacy will be supported, but maybe time for us to move that along

---

<div class="post-metadata">

**Author:** ![rob](https://forums.solar2d.com/user_avatar/forums.solar2d.com/rob/32/4_2.png) [@rob](https://forums.solar2d.com/u/rob)\
**Post date:** [November 21, 2018, 3:37pm UTC](https://forums.solar2d.com/t/illegalstateexception-crashes/348854/13 "2018-11-21T15:37:34Z")

</div>

We should be maintaining&nbsp;that plugin as well. But that doesn’t mean Google isn’t changing something. What we need is to figure out if that’s the cause or not

Rob

---

<div class="post-metadata">

**Author:** ![beernathan](https://forums.solar2d.com/letter_avatar_proxy/v4/letter/b/838e76/32.png) [@beernathan](https://forums.solar2d.com/u/beernathan)\
**Post date:** [November 23, 2018, 12:11am UTC](https://forums.solar2d.com/t/illegalstateexception-crashes/348854/14 "2018-11-23T00:11:58Z")

</div>

OK - making that change in isolation to see if that’s the issue.

---

<div class="post-metadata">

**Author:** ![beernathan](https://forums.solar2d.com/letter_avatar_proxy/v4/letter/b/838e76/32.png) [@beernathan](https://forums.solar2d.com/u/beernathan)\
**Post date:** [November 23, 2018, 1:26am UTC](https://forums.solar2d.com/t/illegalstateexception-crashes/348854/15 "2018-11-23T01:26:47Z")

</div>

Have switched to Notifications v2 (which we are only using for local notifications) but now getting

Issue: java.lang.IllegalStateException: Default FirebaseApp is not initialized in this process com.XXX.XXX. Make sure to call FirebaseApp.initializeApp(Context) first.

Seems strange as the docs say we can do it without using Firebase if we’re not using it for Push [https://docs.coronalabs.com/plugin/notifications-v2/registerForPushNotifications.html](https://docs.coronalabs.com/plugin/notifications-v2/registerForPushNotifications.html)

We have the full log now. Is there a way I can share a log output with you @RobMiracle without exposing it publicly?

---

<div class="post-metadata">

**Author:** ![beernathan](https://forums.solar2d.com/letter_avatar_proxy/v4/letter/b/838e76/32.png) [@beernathan](https://forums.solar2d.com/u/beernathan)\
**Post date:** [November 23, 2018, 5:01am UTC](https://forums.solar2d.com/t/illegalstateexception-crashes/348854/16 "2018-11-23T05:01:01Z")

</div>

So the update is that I was able to build and get it to run with V2, but had to setup a Firebase app (even though it said we didn’t require it).

Will now deploy and see it it keeps getting the crash once live.

---

<div class="post-metadata">

**Author:** ![beernathan](https://forums.solar2d.com/letter_avatar_proxy/v4/letter/b/838e76/32.png) [@beernathan](https://forums.solar2d.com/u/beernathan)\
**Post date:** [November 27, 2018, 12:02am UTC](https://forums.solar2d.com/t/illegalstateexception-crashes/348854/17 "2018-11-27T00:02:34Z")

</div>

Deployed 24 hours ago and crashes are down 98% 🙂

Will report back again in a few days, but at this stage it’s looking good.

Lessons are that Notifications v1 legacy is not longer working (despite docs saying legacy is supported) doc here:&nbsp;[https://docs.coronalabs.com/plugin/notifications/index.html](https://docs.coronalabs.com/plugin/notifications/index.html)

Also Notifications v2 docs need updating (or the bug needs fixing) as it’s not possible to include it without a Firebase app setup (even with FCM set to false).

Doc is here:&nbsp;[https://docs.coronalabs.com/plugin/notifications-v2/registerForPushNotifications.html](https://docs.coronalabs.com/plugin/notifications-v2/registerForPushNotifications.html)

---

<div class="post-metadata">

**Author:** ![alireza.poorsohoolat](https://forums.solar2d.com/letter_avatar_proxy/v4/letter/a/edb3f5/32.png) [@alireza.poorsohoolat](https://forums.solar2d.com/u/alireza.poorsohoolat)\
**Post date:** [November 27, 2018, 10:28am UTC](https://forums.solar2d.com/t/illegalstateexception-crashes/348854/18 "2018-11-27T10:28:18Z")

</div>

On iOS side, I had some problems too. I get these errors when I build my app:  
&nbsp;

```
Undefined symbols for architecture armv7: "\_deflate", referenced from: +[NSData(GTMZlibAdditionsPrivate) gtm\_dataByCompressingBytes:length:compressionLevel:mode:error:] in libGoogleToolboxForMac.a(GTMNSData+zlib\_fc602038fcf7c84186e822a98cfdc996.o) "\_deflateEnd", referenced from: +[NSData(GTMZlibAdditionsPrivate) gtm\_dataByCompressingBytes:length:compressionLevel:mode:error:] in libGoogleToolboxForMac.a(GTMNSData+zlib\_fc602038fcf7c84186e822a98cfdc996.o) "deflateInit2", referenced from: +[NSData(GTMZlibAdditionsPrivate) gtm\_dataByCompressingBytes:length:compressionLevel:mode:error:] in libGoogleToolboxForMac.a(GTMNSData+zlib\_fc602038fcf7c84186e822a98cfdc996.o) "\_inflate", referenced from: +[NSData(GTMZlibAdditionsPrivate) gtm\_dataByInflatingBytes:length:isRawData:error:] in libGoogleToolboxForMac.a(GTMNSData+zlib\_fc602038fcf7c84186e822a98cfdc996.o) "\_inflateEnd", referenced from: +[NSData(GTMZlibAdditionsPrivate) gtm\_dataByInflatingBytes:length:isRawData:error:] in libGoogleToolboxForMac.a(GTMNSData+zlib\_fc602038fcf7c84186e822a98cfdc996.o) "inflateInit2", referenced from: +[NSData(GTMZlibAdditionsPrivate) gtm\_dataByInflatingBytes:length:isRawData:error:] in libGoogleToolboxForMac.a(GTMNSData+zlib\_fc602038fcf7c84186e822a98cfdc996.o)

```

As additional information, I added these libraries to my Xcode project:  
libFirebaseAnalytics,

libGoogleToolboxForMac  
libFirebaseCore, libNotificationsV2Plugin  
libFirebaseInstanceID, libProtobuf  
libFirebaseMessaging

---

<div class="post-metadata">

**Author:** ![beernathan](https://forums.solar2d.com/letter_avatar_proxy/v4/letter/b/838e76/32.png) [@beernathan](https://forums.solar2d.com/u/beernathan)\
**Post date:** [December 3, 2018, 4:34am UTC](https://forums.solar2d.com/t/illegalstateexception-crashes/348854/19 "2018-12-03T04:34:11Z")

</div>

So we did that release and…&nbsp; same problem.

Still getting lots of these:

**java.lang.RuntimeException** :

&nbsp;

at android.app.ActivityThread.handleReceiver (ActivityThread.java:3399)

&nbsp;

at android.app.ActivityThread.-wrap18 (Unknown Source)

&nbsp;

at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1780)

&nbsp;

at android.os.Handler.dispatchMessage (Handler.java:105)

&nbsp;

at android.os.Looper.loop (Looper.java:164)

&nbsp;

at android.app.ActivityThread.main (ActivityThread.java:6940)

&nbsp;

at java.lang.reflect.Method.invoke (Native Method)

&nbsp;

at com.android.internal.os.Zygote$MethodAndArgsCaller.run (Zygote.java:327)

&nbsp;

at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1374)

Caused by: **java.lang.IllegalStateException** :

&nbsp;

at android.app.ContextImpl.startServiceCommon (ContextImpl.java:1538)

&nbsp;

at android.app.ContextImpl.startService (ContextImpl.java:1484)

&nbsp;

at android.content.ContextWrapper.startService (ContextWrapper.java:663)

&nbsp;

at android.content.ContextWrapper.startService (ContextWrapper.java:663)

&nbsp;

at com.ansca.corona.SystemStartupBroadcastReceiver.onReceive (SystemStartupBroadcastReceiver.java:29)

&nbsp;

at android.app.ActivityThread.handleReceiver (ActivityThread.java:3392)

---

<div class="post-metadata">

**Author:** ![rob](https://forums.solar2d.com/user_avatar/forums.solar2d.com/rob/32/4_2.png) [@rob](https://forums.solar2d.com/u/rob)\
**Post date:** [December 3, 2018, 2:19pm UTC](https://forums.solar2d.com/t/illegalstateexception-crashes/348854/20 "2018-12-03T14:19:14Z")

</div>

This is with Notifications V2? Are you still running oneSignal?

[Next page](https://forums.solar2d.com/t/illegalstateexception-crashes/348854.md?page=2)
