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

Error running in release mode #172

Closed
asashour opened this issue Jun 8, 2022 · 8 comments · Fixed by #182
Closed

Error running in release mode #172

asashour opened this issue Jun 8, 2022 · 8 comments · Fixed by #182

Comments

@asashour
Copy link
Contributor

asashour commented Jun 8, 2022

I have an app that works perfectly in debug mode, however once in release mode (so far tested in Android), the background service is not triggered. Not sure if there is an obfuscation somewhere.

Steps:

  1. flutter build apk
  2. flutter install
  3. flutter logs

Which show:

I/flutter ( 1941): main
E/flutter ( 1941): [ERROR:flutter/shell/common/shell.cc(93)] Dart Error: Dart_LookupLibrary: library 'package:flutter_background_service_android/flutter_background_servi
ce_android.dart' not found.
E/flutter ( 1941): [ERROR:flutter/runtime/dart_isolate.cc(669)] Could not resolve main entrypoint function.
E/flutter ( 1941): [ERROR:flutter/runtime/dart_isolate.cc(167)] Could not run the run main Dart entrypoint.
E/flutter ( 1941): [ERROR:flutter/runtime/runtime_controller.cc(385)] Could not create root isolate.
E/flutter ( 1941): [ERROR:flutter/shell/common/shell.cc(604)] Could not launch engine with configuration.

Using flutter master.

flutter doctor -v
[√] Flutter (Channel master, 3.1.0-0.0.pre.1139, on Microsoft Windows [Version 10.0.19044.1706], locale en-US)
    • Flutter version 3.1.0-0.0.pre.1139 at c:\use\flutter
    • Upstream repository https://github.com/asashour/flutter.git
    • Framework revision 2ab56de808 (2 days ago), 2022-06-07 02:18:05 -0400
    • Engine revision 5797ecf2fb
    • Dart version 2.18.0 (build 2.18.0-170.0.dev)
    • DevTools version 2.14.0

Checking Android licenses is taking an unexpectedly long time...[√] Android toolchain - develop for Android devices (Android SDK version 32.0.0)
    • Android SDK at C:\Users\ahmed_ashour\AppData\Local\Android\Sdk
    • Platform android-32, build-tools 32.0.0
    • ANDROID_SDK_ROOT = C:\Users\ahmed_ashour\AppData\Local\Android\Sdk
    • Java binary at: C:\Program Files\Android\Android Studio1\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 11.0.12+7-b1504.28-7817840)
    • All Android licenses accepted.

[√] Chrome - develop for the web
    • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[√] Visual Studio - develop for Windows (Visual Studio Community 2022 17.2.3)
    • Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community
    • Visual Studio Community 2022 version 17.2.32526.322
    • Windows 10 SDK version 10.0.20348.0

[√] Android Studio (version 2021.1)
    • Android Studio at C:\Program Files\Android\Android Studio
    • Flutter plugin can be installed from:
       https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
       https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.12+7-b1504.28-7817840)

[√] Android Studio (version 2021.2)
    • Android Studio at C:\Program Files\Android\Android Studio1
    • Flutter plugin can be installed from:
       https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
       https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.12+7-b1504.28-7817840)

[√] IntelliJ IDEA Community Edition (version 2022.1)
    • IntelliJ at C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2021.2.1
    • Flutter plugin version 68.1.4
    • Dart plugin version 221.5787.37

[√] IntelliJ IDEA Ultimate Edition (version 2022.1)
    • IntelliJ at C:\Program Files\JetBrains\IntelliJ IDEA 221.5080.93
    • Flutter plugin can be installed from:
       https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin version 221.5480

[√] VS Code (version 1.67.1)
    • VS Code at C:\Users\ahmed_ashour\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 3.40.0

[√] Connected device (4 available)
    • SM A226B (mobile) • R9WT30XNMFP • android-arm64  • Android 11 (API 30)
    • Windows (desktop) • windows     • windows-x64    • Microsoft Windows [Version 10.0.19044.1706]
    • Chrome (web)      • chrome      • web-javascript • Google Chrome 102.0.5005.63
    • Edge (web)        • edge        • web-javascript • Microsoft Edge 102.0.1245.33

[√] HTTP Host Availability
    • All required HTTP hosts are available

• No issues found!
@asashour
Copy link
Contributor Author

asashour commented Jun 8, 2022

Closing as this works fine on stable Flutter, I would take it to Flutter team.

@asashour asashour closed this as completed Jun 8, 2022
@asashour
Copy link
Contributor Author

This because @pragma('vm:entry-point') is missing in

and in the example

Please see dart-lang/sdk#49181 (comment)

@Alvarocda
Copy link

Is this fix already available in version 2.1.3?
I'm using this version and this problem is happening.

@asashour
Copy link
Contributor Author

asashour commented Sep 2, 2022

Please see #172 (comment)

@Alvarocda
Copy link

Alvarocda commented Sep 2, 2022

Ok, I managed to solve it, but my flutter_background_service_android.dart file didn't have this line @pragma('vm:entry-point')
on top of the _entrypoint method, after putting it manually, it started to work.

I'm using version 2.1.3

image

@Alvarocda
Copy link

Just to confirm, I created a new project and added this lib to it, and the @pragma('vm:entry-point') annotation on top of the _entrypoint method didn't really come.

It should have come because this annotation is in the master branch of the repository.

@zae1403
Copy link

zae1403 commented Sep 13, 2022

same issue. my device is Pocophone X3 GT with android 12 cannot launch the service when the app build in release mode.

Flutter V3.3
use flutter_background_service: ^2.1.3

E/flutter ( 8225): [ERROR:flutter/shell/common/shell.cc(93)] Dart Error: Dart_LookupLibrary: library 'package:flutter_background_service_android/flutter_background_service_android.dart' not found.
E/flutter ( 8225): [ERROR:flutter/runtime/dart_isolate.cc(668)] Could not resolve main entrypoint function.
E/flutter ( 8225): [ERROR:flutter/runtime/dart_isolate.cc(167)] Could not run the run main Dart entrypoint.
E/flutter ( 8225): [ERROR:flutter/runtime/runtime_controller.cc(385)] Could not create root isolate.
E/flutter ( 8225): [ERROR:flutter/shell/common/shell.cc(604)] Could not launch engine with configuration.

@zae1403
Copy link

zae1403 commented Sep 13, 2022

Ok, I managed to solve it, but my flutter_background_service_android.dart file didn't have this line @pragma('vm:entry-point') on top of the _entrypoint method, after putting it manually, it started to work.

I'm using version 2.1.3

image

just following this and it worked

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants