Skip to content

[BUG] Attempt to read from field 'java.lang.String io.flutter.embedding.engine.loader.FlutterApplicationInfo.flutterAssetsDir' on a null object reference #160

@KorbinianMossandl

Description

@KorbinianMossandl

Your Environment

  • Plugin version: 0.6.0
  • Platform: Android
  • OS version: 10.0
  • Device manufacturer / model: any
  • Flutter info (flutter info, flutter doctor):
[✓] Flutter (Channel master, 1.23.0-19.0.pre.95, on Linux, locale en_US.UTF-8)
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
[✓] Android Studio (version 4.0)
[✓] Connected device (1 available)
  • Plugin config
BackgroundFetchConfig(
          minimumFetchInterval: 30,
          stopOnTerminate: false,
          enableHeadless: true,
          startOnBoot: true,
          requiredNetworkType: NetworkType.ANY,
        )

To Reproduce
Steps to reproduce the behavior:

  1. register headless task with flutter version >=1.22.0
  2. close app
  3. trigger headless task

Debug logs

2020-10-19 14:26:10.786 6164-6164/com.test.app.demo E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.test.app.demo, PID: 6164
    java.lang.NullPointerException: Attempt to read from field 'java.lang.String io.flutter.embedding.engine.loader.FlutterApplicationInfo.flutterAssetsDir' on a null object reference
        at io.flutter.embedding.engine.loader.FlutterLoader.findAppBundlePath(FlutterLoader.java:324)
        at io.flutter.view.FlutterMain.findAppBundlePath(FlutterMain.java:98)
        at com.transistorsoft.flutter.backgroundfetch.HeadlessTask.startBackgroundIsolate(HeadlessTask.java:128)
        at com.transistorsoft.flutter.backgroundfetch.HeadlessTask.dispatch(HeadlessTask.java:101)
        at com.transistorsoft.flutter.backgroundfetch.HeadlessTask.run(HeadlessTask.java:95)
        at android.os.Handler.handleCallback(Handler.java:907)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:216)
        at android.app.ActivityThread.main(ActivityThread.java:7506)
        at java.lang.reflect.Method.invoke(Native Method)
    	at com.android.internal.os.RuntimeInit$MethodAndArgsCal

Additional context
At first glance when you search via google this seems to be a bug in flutter itself
flutter/flutter#64458
but the fix is already on master and as you can see, i still run into this issue.
everything works fine as long as the app is still running and a backround task is triggered. only the headless one crashes with above error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions