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.

[Bug] App crash when clicking notification

See original GitHub issue

[REQUIRED] Please fill in the following fields:

  • Unity editor version: 2020.3.7f1
  • Firebase Unity SDK version: 7.2.0
  • Source you installed the SDK: .unitypackage
  • Problematic Firebase Component: Messaging
  • Other Firebase Components in use: Analytics
  • Additional SDKs you are using: Admob
  • Platform you are using the Unity editor on: Windows
  • Platform you are targeting: Android
  • Scripting Runtime: IL2CPP

[REQUIRED] Please describe the issue here:

When app is running, it will crash when user taps a push notification from the app in the notification tray. (When the app is not open, behavior is normal: tapping a push notification will open the app).

Everything was running fine before. I believe this started after I removed and then re-imported Firebase SDK to my unity project. That may have updated the SDK version (i’m not sure which one i was using before the re-import).

Logs:

0001/01/01 00:00:00.000 -1 -1 Info --------- beginning of crash 2021/06/07 07:32:02.729 9663 9663 Error AndroidRuntime FATAL EXCEPTION: main 2021/06/07 07:32:02.729 9663 9663 Error AndroidRuntime Process: com.xxx.yyy, PID: 9663 2021/06/07 07:32:02.729 9663 9663 Error AndroidRuntime java.lang.IllegalArgumentException: Scheduled service ComponentInfo{com.xxx.yyy/com.google.firebase.messaging.MessageForwardingService} does not require android.permission.BIND_JOB_SERVICE permission 2021/06/07 07:32:02.729 9663 9663 Error AndroidRuntime at android.os.Parcel.createExceptionOrNull(Parcel.java:2389) 2021/06/07 07:32:02.729 9663 9663 Error AndroidRuntime at android.os.Parcel.createException(Parcel.java:2369) 2021/06/07 07:32:02.729 9663 9663 Error AndroidRuntime at android.os.Parcel.readException(Parcel.java:2352) 2021/06/07 07:32:02.729 9663 9663 Error AndroidRuntime at android.os.Parcel.readException(Parcel.java:2294) 2021/06/07 07:32:02.729 9663 9663 Error AndroidRuntime at android.app.job.IJobScheduler$Stub$Proxy.enqueue(IJobScheduler.java:342) 2021/06/07 07:32:02.729 9663 9663 Error AndroidRuntime at android.app.JobSchedulerImpl.enqueue(JobSchedulerImpl.java:56) 2021/06/07 07:32:02.729 9663 9663 Error AndroidRuntime at androidx.core.app.JobIntentService$JobWorkEnqueuer.enqueueWork(JobIntentService.java:343) 2021/06/07 07:32:02.729 9663 9663 Error AndroidRuntime at androidx.core.app.JobIntentService.enqueueWork(JobIntentService.java:523) 2021/06/07 07:32:02.729 9663 9663 Error AndroidRuntime at androidx.core.app.JobIntentService.enqueueWork(JobIntentService.java:501) 2021/06/07 07:32:02.729 9663 9663 Error AndroidRuntime at com.google.firebase.messaging.MessageForwardingService.enqueueWork(MessageForwardingService.java:37) 2021/06/07 07:32:02.729 9663 9663 Error AndroidRuntime at com.google.firebase.MessagingUnityPlayerActivity.onNewIntent(MessagingUnityPlayerActivity.java:75) 2021/06/07 07:32:02.729 9663 9663 Error AndroidRuntime at android.app.Activity.performNewIntent(Activity.java:8213) 2021/06/07 07:32:02.729 9663 9663 Error AndroidRuntime at android.app.Instrumentation.callActivityOnNewIntent(Instrumentation.java:1409) 2021/06/07 07:32:02.729 9663 9663 Error AndroidRuntime at android.app.Instrumentation.callActivityOnNewIntent(Instrumentation.java:1422) 2021/06/07 07:32:02.729 9663 9663 Error AndroidRuntime at android.app.ActivityThread.deliverNewIntents(ActivityThread.java:4031) 2021/06/07 07:32:02.729 9663 9663 Error AndroidRuntime at android.app.ActivityThread.handleNewIntent(ActivityThread.java:4043) 2021/06/07 07:32:02.729 9663 9663 Error AndroidRuntime at android.app.servertransaction.NewIntentItem.execute(NewIntentItem.java:53) 2021/06/07 07:32:02.729 9663 9663 Error AndroidRuntime at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135) 2021/06/07 07:32:02.729 9663 9663 Error AndroidRuntime at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95) 2021/06/07 07:32:02.729 9663 9663 Error AndroidRuntime at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2307) 2021/06/07 07:32:02.729 9663 9663 Error AndroidRuntime at android.os.Handler.dispatchMessage(Handler.java:106) 2021/06/07 07:32:02.729 9663 9663 Error AndroidRuntime at android.os.Looper.loop(Looper.java:246) 2021/06/07 07:32:02.729 9663 9663 Error AndroidRuntime at android.app.ActivityThread.main(ActivityThread.java:8512) 2021/06/07 07:32:02.729 9663 9663 Error AndroidRuntime at java.lang.reflect.Method.invoke(Native Method) 2021/06/07 07:32:02.729 9663 9663 Error AndroidRuntime at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:602) 2021/06/07 07:32:02.729 9663 9663 Error AndroidRuntime at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1130) 2021/06/07 07:32:02.729 9663 9663 Error AndroidRuntime Caused by: android.os.RemoteException: Remote stack trace: 2021/06/07 07:32:02.729 9663 9663 Error AndroidRuntime at com.android.server.job.JobSchedulerService$JobSchedulerStub.enforceValidJobRequest(JobSchedulerService.java:2590) 2021/06/07 07:32:02.729 9663 9663 Error AndroidRuntime at com.android.server.job.JobSchedulerService$JobSchedulerStub.enqueue(JobSchedulerService.java:2673) 2021/06/07 07:32:02.729 9663 9663 Error AndroidRuntime at android.app.job.IJobScheduler$Stub.onTransact(IJobScheduler.java:175) 2021/06/07 07:32:02.729 9663 9663 Error AndroidRuntime at android.os.Binder.execTransactInternal(Binder.java:1190) 2021/06/07 07:32:02.729 9663 9663 Error AndroidRuntime at android.os.Binder.execTransact(Binder.java:1159) 2021/06/07 07:32:02.729 9663 9663 Error AndroidRuntime

Relevant Code:

Here is AndroidManifest file in the Plugins/Android folder:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" package="com.xxx.yyy" android:versionCode="1" android:versionName="1.0">
  <application android:label="@string/app_name" android:icon="@drawable/app_icon" android:theme="@style/UnityThemeSelector">
    <meta-data android:name="unityplayer.SkipPermissionsDialog" android:value="true" />  
    <!-- The MessagingUnityPlayerActivity is a class that extends UnityPlayerActivity to work around a known issue when receiving notification data payloads in the background. -->    
    <activity android:name="com.google.firebase.MessagingUnityPlayerActivity" android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen">
      <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
      </intent-filter>
      <meta-data android:name="unityplayer.UnityActivity" android:value="true" />
    </activity>
    <service android:name="com.google.firebase.messaging.MessageForwardingService" android:exported="false" />
  </application>
</manifest>

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7

github_iconTop GitHub Comments

3reactions
nanddocommented, Jun 7, 2021

@nronaldvdberg @Str4tos I’ve found this thread on stack overflow and it solved the issue in my case. We’re replaced the following line on AndroidManifest.xml:

Before: <service android:name="com.google.firebase.messaging.MessageForwardingService" android:exported="false" /> After…: <service android:name="com.google.firebase.messaging.MessageForwardingService" android:permission="android.permission.BIND_JOB_SERVICE" android:exported="true"/>

This adds the BIND_JOB_SERVICE permission to the build and also sets the exported to true.

We haven’t dig deeper into the solution to fully understand it, though. I’d recommend checking if this works for you too, at least as a temporary fix for the problem.

Important: the step to reproduce provided above works. On our case, we had two devices with different builds (before and after codes above) running in background (i.e. minimized) and we sent a push from Firebase Cloud Messaging. The device with “Before” code crashed when opening the notification, while the device with “After” code worked fine. In more details:

  1. Open the app
  2. Minimize it
  3. Send a notification from Firebase Cloud Message
  4. Tap on the notification
  5. Notice that the app crashes if there’s no BIND_JOB_SERVICE permission added.

Hope that helps!

0reactions
paulinoncommented, Jul 8, 2021

Hi @mgrogin,

It’s possible that this bug has been fixed in the latest version of the SDK (8.0.0) without the help of the workaround. If the issue persists, you may file a new ticket regarding this.

Read more comments on GitHub >

github_iconTop Results From Across the Web

App crashes when clicking on notification
My problem is that when I click on the notification, the app crashes since it says: java.lang.NullPointerException: Attempt to invoke ...
Read more >
Android App randomly crashes when creating notification
I enabled advanced logging on every phone, and what I saw is that the app seems to crash when sending a notification of...
Read more >
App crashes after click in the received push notifications
Something similar happens when the app is in the foreground. When the notification is clicked, the app is closed and the same alert ......
Read more >
IOS 10 crashes caused by Local Notification
I ran into similat situation when trying to scheule mulpile UILocalNofication where "SpringBoard" would hike up the memory and eventualy crash and restart...
Read more >
App crashes after pressing notification on iOS 14 Issue ...
If you are facing issue related to pressing the firebase push notificaion and its crash with this error “Call must be made on...
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