[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:
- Created 2 years ago
- Comments:7
@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 totrue
.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:
BIND_JOB_SERVICE
permission added.Hope that helps!
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.