12

How can I solve this problem:

E/flutter (18287): [ERROR:flutter/shell/common/shell.cc(89)] Dart Error: Dart_LookupLibrary: library 'package:background_fetch/background_fetch.dart' not found.
E/flutter (18287): [ERROR:flutter/runtime/dart_isolate.cc(668)] Could not resolve main entrypoint function.
E/flutter (18287): [ERROR:flutter/runtime/dart_isolate.cc(168)] Could not run the run main Dart entrypoint.
E/flutter (18287): [ERROR:flutter/runtime/runtime_controller.cc(389)] Could not create root isolate.
E/flutter (18287): [ERROR:flutter/shell/common/shell.cc(605)] Could not launch engine with configuration.

the problem just in the mode release, but in the mode debug the plugin is working normally.

More details:

[✓] Flutter (Channel master, 3.4.0-36.0.pre.8, on Ubuntu 22.04.1 LTS 5.15.0-48-generic, locale en_US.UTF-8) Checking Android licenses is taking an unexpectedly long time...[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
[✓] Chrome - develop for the web
[✓] Linux toolchain - develop for Linux desktop
[✓] Android Studio (version 2021.2)
[✓] Android Studio (version 2021.3)
[✓] Android Studio
[✓] VS Code
[✓] Connected device (3 available)
[✓] HTTP Host Availability

Thank you.

Dr Mido
  • 2,414
  • 4
  • 32
  • 72
Maalmi
  • 123
  • 5

1 Answers1

17

add @pragma('vm:entry-point') to background entry-point function

autop
  • 308
  • 2
  • 6
  • This solved it for me. I actually thought that the proguard file was enough to avoid the removing of "unused classes/methods" but apparently it wasnt. – Christian X Oct 17 '22 at 10:59
  • can you explain how ? – Bilal Almefleh Nov 30 '22 at 09:58
  • 1
    @BilalAlmefleh It's not called by your Dart code, so the compiler thinks it's an unused function and can get rid of it. This pragma tells it not to. See https://github.com/dart-lang/sdk/blob/master/runtime/docs/compiler/aot/entry_point_pragma.md – Jaween Feb 06 '23 at 01:24