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

Service does not start automatically after reboot #2

Closed
delacernamarimar opened this issue Sep 21, 2020 · 13 comments
Closed

Service does not start automatically after reboot #2

delacernamarimar opened this issue Sep 21, 2020 · 13 comments

Comments

@delacernamarimar
Copy link

The default package not working in my end tried API levels 26, 28, and 29. Working when run from the studio but when rebooting not working. Working with android as for now but will do IOS later, any suggestions?

@ekasetiawans
Copy link
Owner

can you provide more detailed information?

@delacernamarimar
Copy link
Author

Screen Shot 2020-09-21 at 1 39 30 PM

this is only the return after reboot,

Notification is:
Background Service
Preparing

which this code will trigger
Screen Shot 2020-09-21 at 1 41 19 PM

@ekasetiawans
Copy link
Owner

@delacernamarimar try to run the application at least 1 time directly from the home screen without a studio. Because the plugin requires a callback handle ID for the method to be executed, while the callback handle ID for the same method will have different values when the debuger is attached.

@delacernamarimar
Copy link
Author

@delacernamarimar try to run the application at least 1 time directly from the home screen without a studio. Because the plugin requires a callback handle ID for the method to be executed, while the callback handle ID for the same method will have different values when the debugger is attached.

will try, will let you know

@delacernamarimar
Copy link
Author

@delacernamarimar try to run the application at least 1 time directly from the home screen without a studio. Because the plugin requires a callback handle ID for the method to be executed, while the callback handle ID for the same method will have different values when the debugger is attached.

Same stuck at preparing
Notification is:
Background Service
Preparing

@ekasetiawans
Copy link
Owner

@delacernamarimar , it is an indication that the background service is running successfully. To update the notification, you can use the following method

...
import 'package:flutter_background_service/flutter_background_service.dart';

void main(){
  WidgetsFlutterBinding.ensureInitialized();
  FlutterBackgroundService.initialize(startService);
  runApp(MyApp());
}

void startService(){
  WidgetsFlutterBinding.ensureInitialized();
  final service = FlutterBackgroundService();

  // update notification info
  service.setNotificationInfo(
    title: "My App",
    content: "Hello world",
  );
}

@delacernamarimar
Copy link
Author

@delacernamarimar , it is an indication that the background service is running successfully. To update the notification, you can use the following method

...
import 'package:flutter_background_service/flutter_background_service.dart';

void main(){
  WidgetsFlutterBinding.ensureInitialized();
  FlutterBackgroundService.initialize(startService);
  runApp(MyApp());
}

void startService(){
  WidgetsFlutterBinding.ensureInitialized();
  final service = FlutterBackgroundService();

  // update notification info
  service.setNotificationInfo(
    title: "My App",
    content: "Hello world",
  );
}

Attached is the logcat and the emulator screenshot.

image

device-2020-09-22-014932

full logcat from reboot

2020-09-22 01:47:02.141 502-572/? I/SystemServerTimingAsync: InitThreadPoolExec:Update app-ops uidState in case package id.flutter.flutter_background_service_example changed
2020-09-22 01:47:02.962 502-502/? V/StorageManagerService: Package id.flutter.flutter_background_service_example does not have legacy storage
2020-09-22 01:47:31.936 502-529/? I/ActivityManager: Start proc 3795:id.flutter.flutter_background_service_example/u0a156 for broadcast {id.flutter.flutter_background_service_example/id.flutter.flutter_background_service.BootReceiver}
2020-09-22 01:47:32.156 502-556/? W/ActivityManager: Foreground service started from background can not have location/camera/microphone access: service id.flutter.flutter_background_service_example/id.flutter.flutter_background_service.BackgroundService
2020-09-22 01:47:32.165 502-556/? W/ActivityManager: Foreground service started from background can not have location/camera/microphone access: service id.flutter.flutter_background_service_example/id.flutter.flutter_background_service.BackgroundService
2020-09-22 01:47:32.181 3795-3795/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: id.flutter.flutter_background_service_example, PID: 3795
java.lang.UnsatisfiedLinkError: No implementation found for io.flutter.view.FlutterCallbackInformation io.flutter.embedding.engine.FlutterJNI.nativeLookupCallbackInformation(long) (tried Java_io_flutter_embedding_engine_FlutterJNI_nativeLookupCallbackInformation and Java_io_flutter_embedding_engine_FlutterJNI_nativeLookupCallbackInformation__J)
at io.flutter.embedding.engine.FlutterJNI.nativeLookupCallbackInformation(Native Method)
at io.flutter.view.FlutterCallbackInformation.lookupCallbackInformation(FlutterCallbackInformation.java:30)
at id.flutter.flutter_background_service.BackgroundService.runService(BackgroundService.java:125)
at id.flutter.flutter_background_service.BackgroundService.onStartCommand(BackgroundService.java:112)
at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:4326)
at android.app.ActivityThread.access$1800(ActivityThread.java:237)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1951)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7656)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
2020-09-22 01:47:32.222 502-1715/? I/ActivityManager: Process id.flutter.flutter_background_service_example (pid 3795) has died: prcp FGS
2020-09-22 01:47:32.223 502-1715/? W/ActivityManager: Scheduling restart of crashed service id.flutter.flutter_background_service_example/id.flutter.flutter_background_service.BackgroundService in 1000ms for start-requested
2020-09-22 01:47:32.359 502-502/? D/NotificationService: 0|id.flutter.flutter_background_service_example|99778|null|10156: granting content://settings/system/notification_sound
2020-09-22 01:47:32.359 502-502/? D/NotificationService: 0|id.flutter.flutter_background_service_example|99778|null|10156: granting content://settings/system/notification_sound
2020-09-22 01:47:32.395 668-668/? D/InterruptionStateProvider: No bubble up: not allowed to bubble: 0|id.flutter.flutter_background_service_example|99778|null|10156
2020-09-22 01:47:32.395 668-668/? D/InterruptionStateProvider: No heads up: unimportant notification: 0|id.flutter.flutter_background_service_example|99778|null|10156
2020-09-22 01:47:32.403 668-668/? D/InterruptionStateProvider: No bubble up: not allowed to bubble: 0|id.flutter.flutter_background_service_example|99778|null|10156
2020-09-22 01:47:32.403 668-668/? D/InterruptionStateProvider: No heads up: unimportant notification: 0|id.flutter.flutter_background_service_example|99778|null|10156
2020-09-22 01:47:33.230 502-517/? W/ActivityManager: Stopping service due to app idle: u0a156 -1s99ms id.flutter.flutter_background_service_example/id.flutter.flutter_background_service.BackgroundService
2020-09-22 01:47:33.238 502-529/? I/ActivityManager: Start proc 3906:id.flutter.flutter_background_service_example/u0a156 for service {id.flutter.flutter_background_service_example/id.flutter.flutter_background_service.BackgroundService}
2020-09-22 01:47:33.242 3906-3906/id.flutter.flutter_background_service_example I/service_exampl: Not late-enabling -Xcheck:jni (already on)
2020-09-22 01:47:33.258 3906-3906/id.flutter.flutter_background_service_example I/service_exampl: Unquickening 12 vdex files!
2020-09-22 01:47:33.259 3906-3906/id.flutter.flutter_background_service_example W/service_exampl: Unexpected CPU variant for X86 using defaults: x86
2020-09-22 01:47:33.390 3906-3906/id.flutter.flutter_background_service_example D/ApplicationLoaders: Returning zygote-cached class loader: /system/framework/android.test.base.jar
2020-09-22 01:47:33.420 3906-3906/id.flutter.flutter_background_service_example D/NetworkSecurityConfig: No Network Security Config specified, using platform default
2020-09-22 01:47:33.421 3906-3906/id.flutter.flutter_background_service_example D/NetworkSecurityConfig: No Network Security Config specified, using platform default
2020-09-22 01:47:33.473 3906-3953/id.flutter.flutter_background_service_example I/ResourceExtractor: Found extracted resources res_timestamp-1-1600709809189
2020-09-22 01:47:33.476 3906-3906/id.flutter.flutter_background_service_example E/BackgroundService: callback handle not found
2020-09-22 01:47:33.489 3906-3906/id.flutter.flutter_background_service_example D/AndroidRuntime: Shutting down VM
2020-09-22 01:47:33.491 3906-3906/id.flutter.flutter_background_service_example E/AndroidRuntime: FATAL EXCEPTION: main
Process: id.flutter.flutter_background_service_example, PID: 3906
java.lang.RuntimeException: Unable to stop service id.flutter.flutter_background_service.BackgroundService@9a49370: java.lang.NullPointerException: Attempt to invoke virtual method 'io.flutter.embedding.engine.plugins.service.ServiceControlSurface io.flutter.embedding.engine.FlutterEngine.getServiceControlSurface()' on a null object reference
at android.app.ActivityThread.handleStopService(ActivityThread.java:4375)
at android.app.ActivityThread.access$1900(ActivityThread.java:237)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1956)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7656)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'io.flutter.embedding.engine.plugins.service.ServiceControlSurface io.flutter.embedding.engine.FlutterEngine.getServiceControlSurface()' on a null object reference
at id.flutter.flutter_background_service.BackgroundService.onDestroy(BackgroundService.java:75)
at android.app.ActivityThread.handleStopService(ActivityThread.java:4355)
at android.app.ActivityThread.access$1900(ActivityThread.java:237) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1956) 
at android.os.Handler.dispatchMessage(Handler.java:106) 
at android.os.Looper.loop(Looper.java:223) 
at android.app.ActivityThread.main(ActivityThread.java:7656) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947) 
2020-09-22 01:47:33.525 502-502/? D/NotificationService: 0|id.flutter.flutter_background_service_example|99778|null|10156: granting content://settings/system/notification_sound
2020-09-22 01:47:33.526 502-502/? D/NotificationService: 0|id.flutter.flutter_background_service_example|99778|null|10156: granting content://settings/system/notification_sound
2020-09-22 01:47:33.539 668-668/? D/InterruptionStateProvider: No bubble up: not allowed to bubble: 0|id.flutter.flutter_background_service_example|99778|null|10156
2020-09-22 01:47:33.540 668-668/? D/InterruptionStateProvider: No heads up: unimportant notification: 0|id.flutter.flutter_background_service_example|99778|null|10156
2020-09-22 01:48:38.492 502-528/? W/BroadcastQueue: Receiver during timeout of BroadcastRecord{194a892 u0 null} : ResolveInfo{c35b3ae id.flutter.flutter_background_service_example/id.flutter.flutter_background_service.WatchdogReceiver m=0x0}
2020-09-22 01:48:38.515 502-4228/? I/ActivityManager: Crashing app skipping ANR: ProcessRecord{84c74d4 3906:id.flutter.flutter_background_service_example/u0a156} Broadcast of Intent { flg=0x14 cmp=id.flutter.flutter_background_service_example/id.flutter.flutter_background_service.WatchdogReceiver (has extras) }
2020-09-22 01:48:38.515 502-4228/? D/ActivityManager: Completed ANR of id.flutter.flutter_background_service_example in 23ms, latency 0ms
2020-09-22 01:50:53.322 502-528/? W/ActivityManager: Timeout executing service: ServiceRecord{81d71d4 u0 id.flutter.flutter_background_service_example/id.flutter.flutter_background_service.BackgroundService}
2020-09-22 01:50:53.331 502-4274/? I/ActivityManager: Crashing app skipping ANR: ProcessRecord{84c74d4 3906:id.flutter.flutter_background_service_example/u0a156} executing service id.flutter.flutter_background_service_example/id.flutter.flutter_background_service.BackgroundService

@ekasetiawans
Copy link
Owner

@delacernamarimar I just updated the plugin, can you try again using the latest version and tell me the result?

@delacernamarimar
Copy link
Author

@delacernamarimar I just updated the plugin, can you try again using the latest version and tell me the result?

Sure my pleasure will update you.

@ekasetiawans
Copy link
Owner

ekasetiawans commented Sep 21, 2020

the latest version should be 0.0.1+14 it may take some time for pub.dev to appear

@delacernamarimar
Copy link
Author

delacernamarimar commented Sep 21, 2020

the latest version should be 0.0.1+14 it may take some time for pub.dev to appear

Working now tested in API 30 with notification but for API 23 no notification but the audio is working in the background.

@ekasetiawans
Copy link
Owner

the latest version should be 0.0.1+14 it may take some time for pub.dev to appear

Working now tested in API 30 with notification but for API 23 no notification but the audio is working in the background.

The plugin will use a background service if the application is run on a device with an OS under API 26 (Oreo), otherwise it will use the foreground service to overcome Background Execution Limits.

@ekasetiawans
Copy link
Owner

closed this issue because it was solved

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