Flutter Android Push Notification Handling Error

In the Android build of my Flutter application, the app fails to properly process push notifications that are received while the app is not running. When the app is either running and visible, or running and backgrounded, push notifications are received and processed as expected.

The following error is thrown and displayed in the Flutter debugging console when a push notification is received by the unopened app:

E/AndroidRuntime(23160): java.lang.RuntimeException: Unable to create service com.backendless.backendless_sdk.common.FlutterBackendlessFCMService: java.lang.NullPointerException: Attempt to invoke virtual method 'int com.backendless.BackendlessPrefs.getNotificationIdGeneratorInitValue()' on a null object reference
E/AndroidRuntime(23160):        at android.app.ActivityThread.handleCreateService(ActivityThread.java:4567)
E/AndroidRuntime(23160):        at android.app.ActivityThread.access$1700(ActivityThread.java:256)
E/AndroidRuntime(23160):        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2110)
E/AndroidRuntime(23160):        at android.os.Handler.dispatchMessage(Handler.java:106)
E/AndroidRuntime(23160):        at android.os.Looper.loopOnce(Looper.java:201)
E/AndroidRuntime(23160):        at android.os.Looper.loop(Looper.java:288)
E/AndroidRuntime(23160):        at android.app.ActivityThread.main(ActivityThread.java:7870)
E/AndroidRuntime(23160):        at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(23160):        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
E/AndroidRuntime(23160):        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
E/AndroidRuntime(23160): Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'int com.backendless.BackendlessPrefs.getNotificationIdGeneratorInitValue()' on a null object reference
E/AndroidRuntime(23160):        at com.backendless.push.BackendlessFCMService.<init>(Unknown Source:15)
E/AndroidRuntime(23160):        at com.backendless.backendless_sdk.common.FlutterBackendlessFCMService.<init>(Unknown Source:0)
E/AndroidRuntime(23160):        at java.lang.Class.newInstance(Native Method)
E/AndroidRuntime(23160):        at android.app.AppComponentFactory.instantiateService(AppComponentFactory.java:129)
E/AndroidRuntime(23160):        at androidx.core.app.CoreComponentFactory.instantiateService(Unknown Source:0)
E/AndroidRuntime(23160):        at android.app.ActivityThread.handleCreateService(ActivityThread.java:4536)
E/AndroidRuntime(23160):        ... 9 more

It seems related to preference initialization/existence and I have experimented with the order of various initialization logic but have yet to come up with anything that resolves this issue.

The issue is pretty critical because the crash occurs during the processing of the notification, and so the notifications are never properly delivered/made visible to the app user.

I have just recently started working with the push notification functionality, again, because of the recent update to handle the Android SDK 31 messaging intent issue.

The issue seems related to an old issue that was resolved a few years ago:
NullPointerException in BackendlessFCMService when app is killed - Bug - Backendless Support

Backendless Version (3.x / 5.x, Online / Managed / Pro )


Client SDK (REST / Android / Objective-C / Swift / JS )

Backendless Flutter SDK: 7.3.5

Application ID


Expected Behavior

Please describe the expected behavior of the issue, starting from the first action.

  1. Send a push notification template from the Backendless Console
  2. Push notification is handled while mobile app is closed

Actual Behavior

  1. Send a push notification template from the Backendless Console
  2. Processing of push notification crashes when app is closed

Hello, @Mark_Moline.

I will check into this issue. Thank you for information.

Regards, Nikita.

@Nikita_Fedorishchev Good morning Nikita, have you made any progress on this? Is there anything else we can provide to assist?

Hello, @Matt_Olson.

So far there is no news. As soon as we have something, we will definitely let you know.

Regards, Nikita.


We have 3 apps that we are unable to launch until this is resolved. If there is even a work around until a solution is found I’d be more than happy with that. I know you said that you will let us know when a solution is found, we are in a holding pattern until this is resolved.


Matt Olson

Hello, @Matt_Olson.

We have started to solve this problem. We managed to reproduce it. We are investigating the issue.

Regards, Nikita.

1 Like

Hi Nikita,

I’m sure all the support staff is very busy with all the tickets that come in but I was wondering if you could give us an update on this issue? Again I have 3 new apps I am unable to publish(paying for 2 of them right now)until this is resolved.


Matt Olson

Hello, @Matt_Olson.

We have investigated this problem, and made a separate ticket for this task. At the moment, our developer is busy with a higher priority task and has not yet begun to deal with it.
Sorry for the inconvenience. We have increased the priority of this task.

Regards, Nikita.


Any update here, we are on day 23 since this issue was first submitted and as I’ve stated we are unable to publish our released apps for our customers with this bug.

Thanks, Matt

Hello @Matt_Olson ,
Sorry about the wait, our developers still working on the solution.

Hello, @Matt_Olson, @Mark_Moline.

Our developer started working on solving the problem, I think that it will be solved within a few days."

Regards, Nikita.

@Nikita_Fedorishchev Any update on this, we are over a month now and are still unable to publish our android version of our apps without having this fix implemented.

We’ve prepared the fix.
New java/android sdk is here: Releases · Backendless/java-sdk · GitHub

Also the new codegen on the server side (which will include fixed versions of sdk) will be released in an hour.

Hello, @Matt_Olson.

I will publish new version of backendless-sdk for Flutter today.

Regards, Nikita.

Thank you.

Released in 7.3.6.

When I switch to version 7.3.6 of the Flutter SDK I get the following error from API calls that otherwise were working in version 7.3.5:

{"code":6017,"message":"Content type 'application/x-amf' is not allowed for upload files. Use 'multipart/form-data' or 'application/json'.","errorData":{}}

Searching for a solution it appears that this error can be related to Backendless initialization so I have attempted different configurations of calling Backendless.initApp() but none seem to work. The following works with version 7.3.5:

return await Backendless.initApp(
    applicationId: config["applicationID"],
    customDomain: config["applicationSubDomain"],
    androidApiKey: config["androidAPIKey"],
    iosApiKey: config["iOSAPIKey"],
    jsApiKey: config["iOSAPIKey"]

where the “config” object is properly populated with the respective values/keys.

Any ideas of what needs to be changed?

Continued testing suggests that this issue is isolated to Android Flutter builds. Both web and iOS seem to work properly with Backendless Flutter version 7.3.6.

Hello @Mark_Moline.

What specific query caused this problem for you?

Regards, Nikita.

From what I can tell - all of them. Starting with:


for example.