Skip to content

fix(android): prevent crash if callbackInfo is null in BackgroundWorker (fixes #527)#619

Closed
Tulleb wants to merge 1 commit intofluttercommunity:mainfrom
Tulleb:fix/527
Closed

fix(android): prevent crash if callbackInfo is null in BackgroundWorker (fixes #527)#619
Tulleb wants to merge 1 commit intofluttercommunity:mainfrom
Tulleb:fix/527

Conversation

@Tulleb
Copy link

@Tulleb Tulleb commented Jul 17, 2025

Fixes #527 and also properly compile.

The previously opened PR #615 is currently having the following issue.

@jonathanduke let me know if you commit a fix on your PR; I'll close this one then.

@docs-page
Copy link

docs-page bot commented Jul 17, 2025

To view this pull requests documentation preview, visit the following URL:

docs.page/fluttercommunity/flutter_workmanager~619

Documentation is deployed and generated using docs.page.

@Tulleb Tulleb changed the title Fix null pointer exception fatal error fix(android): prevent crash if callbackInfo is null in BackgroundWorker (fixes #527) Jul 17, 2025
jonathanduke added a commit to jonathanduke/flutter_workmanager that referenced this pull request Jul 18, 2025
@Tulleb
Copy link
Author

Tulleb commented Jul 18, 2025

Closed after #615's fix 👍

@Tulleb Tulleb closed this Jul 18, 2025
@kedaly
Copy link

kedaly commented Jul 20, 2025

A quick question, what is the cadence of release of this fix?

If I am affected by it, how would I access it?

Do I need to simply use a branch of this project, or will there be a release to pub.dev soon?

@Tulleb
Copy link
Author

Tulleb commented Jul 20, 2025

A quick question, what is the cadence of release of this fix?

If I am affected by it, how would I access it?

Do I need to simply use a branch of this project, or will there be a release to pub.dev soon?

Sorry I can't really say about the cadence of release.

But in the meantime, you can add this at the end of your pubspec.yaml file, until the #615 is merged and released:

dependency_overrides:
  # TODO: Rebase on official repo once fixed
  # https://github.com/fluttercommunity/flutter_workmanager/pull/619
  workmanager:
    git:
      url: https://github.com/tulleb/flutter_workmanager.git
      ref: fix/527
      path: workmanager
  workmanager_android:
    git:
      url: https://github.com/tulleb/flutter_workmanager.git
      ref: fix/527
      path: workmanager_android
  workmanager_apple:
    git:
      url: https://github.com/tulleb/flutter_workmanager.git
      ref: fix/527
      path: workmanager_apple
  workmanager_platform_interface:
    git:
      url: https://github.com/tulleb/flutter_workmanager.git
      ref: fix/527
      path: workmanager_platform_interface

@answer0732
Copy link

Hi, thank you very much for providing this workaround.

I was wondering if this fix also resolves the problem discussed in issue #621?

Appreciate your support!

@Tulleb
Copy link
Author

Tulleb commented Jul 21, 2025

Hi, thank you very much for providing this workaround.

I was wondering if this fix also resolves the problem discussed in issue #621?

Appreciate your support!

Yes it should fix it 👍
Your crash stacktrace looks the same.

@Muneeza-PT
Copy link

I am also facing this issue
App crash after update and this is crash log:

Issue details
io.flutter.embedding.engine.dart.DartExecutor$DartCallback.toString
java.lang.NullPointerException

Exception java.lang.NullPointerException: Attempt to read from field 'java.lang.String io.flutter.view.FlutterCallbackInformation.callbackLibraryPath' on a null object reference in method 'java.lang.String io.flutter.embedding.engine.dart.DartExecutor$DartCallback.toString()'
at io.flutter.embedding.engine.dart.DartExecutor$DartCallback.toString (DartExecutor.java:426)
at java.lang.String.valueOf (String.java:4112)
at java.lang.StringBuilder.append (StringBuilder.java:179)
at io.flutter.embedding.engine.dart.DartExecutor.executeDartCallback (DartExecutor.java:181)
at dev.fluttercommunity.workmanager.BackgroundWorker.startWork$lambda$5 (BackgroundWorker.kt:111)
at android.os.Handler.handleCallback (Handler.java:942)
at android.os.Handler.dispatchMessage (Handler.java:99)
at android.os.Looper.loopOnce (Looper.java:204)
at android.os.Looper.loop (Looper.java:291)
at android.app.ActivityThread.main (ActivityThread.java:8168)
at java.lang.reflect.Method.invoke
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:601)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1136)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

java.lang.NullPointerException while app is in backeground around 2 hours than it's getting crashed

4 participants