Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Incompatibility with other plugins #22

Closed
ehhc opened this issue Apr 10, 2019 · 8 comments
Closed

[BUG] Incompatibility with other plugins #22

ehhc opened this issue Apr 10, 2019 · 8 comments

Comments

@ehhc
Copy link

ehhc commented Apr 10, 2019

Your Environment

  • Plugin version: 0.2.0
  • Platform: Android
  • OS version: Windows
  • Device manufacturer / model:
  • Plugin config: --> Example folder

To Reproduce
Steps to reproduce the behavior:

  1. Open the example project
  2. Add image_picker: 0.4.12+1 as a dependency
  3. Install app
  4. Close app (minimizinig is not enough)
  5. Trigger a headless background fetch event => adb shell cmd jobscheduler run -f com.transistorsoft.flutter.backgroundfetch.backgroundfetchexample 999
  6. See error below

Debug logs

04-10 10:56:12.838 16400 16400 D TSBackgroundFetch: - Background Fetch event received
04-10 10:56:12.850 16400 16400 D TSBackgroundFetch: - finish
04-10 10:56:12.850 16400 16400 D TSBackgroundFetch: - jobFinished
04-10 10:56:12.865 16400 16400 D TSBackgroundFetch: HeadlessJobService onStartJob
04-10 10:56:12.866 16400 16400 D TSBackgroundFetch: 💀 [HeadlessTask]
04-10 10:56:13.247 16400 16400 E JobServiceEngine: Error while executing job: 998
04-10 10:56:13.248 16400 16400 D AndroidRuntime: Shutting down VM
04-10 10:56:13.257 16400 16400 E AndroidRuntime: FATAL EXCEPTION: main
04-10 10:56:13.257 16400 16400 E AndroidRuntime: Process: com.transistorsoft.flutter.backgroundfetch.backgroundfetchexample, PID: 16400
04-10 10:56:13.257 16400 16400 E AndroidRuntime: java.lang.RuntimeException: java.lang.NullPointerException: Attempt to invoke virtual method 'java.io.File android.app.Activity.getExternalFilesDir(java.lang.String)' on a null object reference
04-10 10:56:13.257 16400 16400 E AndroidRuntime:        at android.app.job.JobServiceEngine$JobHandler.handleMessage(JobServiceEngine.java:112)
04-10 10:56:13.257 16400 16400 E AndroidRuntime:        at android.os.Handler.dispatchMessage(Handler.java:106)
04-10 10:56:13.257 16400 16400 E AndroidRuntime:        at android.os.Looper.loop(Looper.java:164)
04-10 10:56:13.257 16400 16400 E AndroidRuntime:        at android.app.ActivityThread.main(ActivityThread.java:6494)
04-10 10:56:13.257 16400 16400 E AndroidRuntime:        at java.lang.reflect.Method.invoke(Native Method)
04-10 10:56:13.257 16400 16400 E AndroidRuntime:        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
04-10 10:56:13.257 16400 16400 E AndroidRuntime:        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
04-10 10:56:13.257 16400 16400 E AndroidRuntime: Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.io.File android.app.Activity.getExternalFilesDir(java.lang.String)' on a null object reference
04-10 10:56:13.257 16400 16400 E AndroidRuntime:        at io.flutter.plugins.imagepicker.ImagePickerPlugin.registerWith(ImagePickerPlugin.java:27)
04-10 10:56:13.257 16400 16400 E AndroidRuntime:        at io.flutter.plugins.GeneratedPluginRegistrant.registerWith(GeneratedPluginRegistrant.java:17)
04-10 10:56:13.257 16400 16400 E AndroidRuntime:        at com.transistorsoft.flutter.backgroundfetch.backgroundfetchexample.Application.registerWith(Application.java:17)
04-10 10:56:13.257 16400 16400 E AndroidRuntime:        at com.transistorsoft.flutter.backgroundfetch.HeadlessTask.initFlutterView(HeadlessTask.java:133)
04-10 10:56:13.257 16400 16400 E AndroidRuntime:        at com.transistorsoft.flutter.backgroundfetch.HeadlessTask.<init>(HeadlessTask.java:47)
04-10 10:56:13.257 16400 16400 E AndroidRuntime:        at com.transistorsoft.flutter.backgroundfetch.HeadlessJobService.onStartJob(HeadlessJobService.java:38)
04-10 10:56:13.257 16400 16400 E AndroidRuntime:        at android.app.job.JobService$1.onStartJob(JobService.java:71)
04-10 10:56:13.257 16400 16400 E AndroidRuntime:        at android.app.job.JobServiceEngine$JobHandler.handleMessage(JobServiceEngine.java:108)
04-10 10:56:13.257 16400 16400 E AndroidRuntime:        ... 6 more
04-10 10:56:13.273   767   782 I ActivityManager: Showing crash dialog for package com.transistorsoft.flutter.backgroundfetch.backgroundfetchexample u0
04-10 10:56:13.281   767   781 W BroadcastQueue: Background execution not allowed: receiving Intent { act=android.intent.action.DROPBOX_ENTRY_ADDED flg=0x10 (has extras) } to com.google.android.gms/.stats.service.DropBoxEntryAddedReceiver
04-10 10:56:13.281   767   781 W BroadcastQueue: Background execution not allowed: receiving Intent { act=android.intent.action.DROPBOX_ENTRY_ADDED flg=0x10 (has extras) } to com.google.android.gms/.chimera.GmsIntentOperationService$PersistentTrustedReceiver

Do you have any ideas how to fix this? :)

@christocracy
Copy link
Member

It's due to a bug in image_picker, which they fixed in 0.5.0+3. Upgrade to latest image_picker.

@ehhc
Copy link
Author

ehhc commented Apr 10, 2019

oh, .. thanks for the quick response

@christocracy
Copy link
Member

christocracy commented Apr 10, 2019

When your app boots Headless, many plugins make the mistake of naively referencing registrar.activity(). There is no Activity in Headless Mode.

Plugins need to first check if (registrar.activity() != null) { }, which is what image_picker did in their v0.5.0+3

@ehhc
Copy link
Author

ehhc commented Apr 10, 2019

The location plugin has the same problem -.-

btw: is there anyway to un-register a headless task? Since i don't have to start the background_fetch for headless tasks, i assume, i cannot stop it by calling BackgroundFetch.stop()??

@christocracy
Copy link
Member

The location plugin has the same problem -.-

What location plugin? Why don't you use my flutter_background_geolocation?

is there anyway to un-register a headless task?

Why would you do that? Just call #stop.

@ehhc
Copy link
Author

ehhc commented Apr 10, 2019

this plugin: https://github.com/Lyokone/flutterlocation
I need it to access the location while the app is in the foreground.
But thanks to your hint above i was able to fix the issue and create a PR (see the referenced issue above) thanks therefore.

Anyway: I still plan to use your background_geolocation plugin as well. For location tracking. Unfortunately, the app I'm developing is part of a research project for my university. Therefore, I'll not be able to buy your plugin because it's only a prototype, we're developing :(

is there anyway to un-register a headless task?

Why would you do that? Just call #stop.

You're right: that question was stupid.

Thanks a lot for your quick and good help :)

@christocracy
Copy link
Member

Anyway: I still plan to use your background_geolocation plugin as well.

This is what you pay for: full time support. This plugin is not a side-project, I've supported it full time for > 4 years (it was originally developed for Cordova and React Native).

@ehhc
Copy link
Author

ehhc commented Apr 10, 2019

if i would be able to buy it, i would like to. But as i said, it's just a research prototype, so that's a bit difficult.. :(
Nonetheless, i will try to figure out if there is a way to buy a licence of your plugin, even though i fear that's unlikely :(

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

No branches or pull requests

2 participants