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

🐞Not working on Android Release when obfuscated to show Local Notifications #374

Open
brunodmn opened this issue Apr 4, 2022 · 7 comments
Labels
bug Something isn't working

Comments

@brunodmn
Copy link

brunodmn commented Apr 4, 2022

Describe the bug
I am trying to show local notifications from workmanager. It works fine when I run on my physical Android device locally, but when I build an appbundle obfuscating the code, it won't work nor throw errors. I've tried with Flutter Local Notifications and with Awesome Notifications.
If I request to show notification from main thread, it works even when obfuscated the code. It won't work only if I call a Workmanager task and use the show method inside callbackdispatcher();

To Reproduce
I've created a fresh application with implementation of packages Workmanager and Flutter Local Notifications.

  1. Clone this sample;
  2. Add key.porperties to sign the bundle;
  3. Run flutter build appbundle --obfuscate --split-debug-info={$FOLDER} to create a bundle (replace $FOLDER with existing location)
  4. Install it on your Android device (You can use Internal App Sharing)

Expected behavior
Local notification should be shown on app initialization

Sample code to reproduce the problem
Sample Code

flutter doctor -v

[✓] Flutter (Channel stable, 2.10.4, on Linux Mint 20.3 5.4.0-107-generic,
locale en_US.UTF-8)
• Flutter version 2.10.4 at /home/bruno/_development/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision c860cba910 (11 days ago), 2022-03-25 00:23:12 -0500
• Engine revision 57d3bac3dd
• Dart version 2.16.2
• DevTools version 2.9.2

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
• Android SDK at /home/bruno/Android/Sdk
• Platform android-31, build-tools 30.0.3
• Java binary at: /snap/android-studio/current/android-studio/jre/bin/java
• Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7590822)
• All Android licenses accepted.

[✓] Chrome - develop for the web
• Chrome at google-chrome

[✓] Linux toolchain - develop for Linux desktop
• clang version 10.0.0-4ubuntu1
• cmake version 3.16.3
• ninja version 1.10.0
• pkg-config version 0.29.1

[✓] Android Studio
• Android Studio at /snap/android-studio/current/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
• android-studio-dir = /snap/android-studio/current/android-studio
• Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7590822)

[✓] VS Code (version 1.66.0)
• VS Code at /usr/share/code
• Flutter extension version 3.38.0

[✓] Connected device (2 available)
• Linux (desktop) • linux • linux-x64 • Linux Mint 20.3
5.4.0-107-generic
• Chrome (web) • chrome • web-javascript • Google Chrome 100.0.4896.60

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

• No issues found!

@brunodmn brunodmn added the bug Something isn't working label Apr 4, 2022
@jafitz26
Copy link

Any updates on this?

I have the same issue for Android 12 only, but removing --obfuscate does not solve it. Everything runs perfectly on Android 10.

@absar
Copy link
Contributor

absar commented Jun 3, 2022

It is not only an issue with other plugins called by workmanager, rather running workmanager itself when obfuscating any App built with Flutter v2.10+.
Same issue in Flutter 3, workmanager doesn't even run the call back in obfuscated Apps, which is a blocker since we are unable to release Apps with obfuscation.
You can reproduce it with any obfuscated app, no need to create appbundle and upload to play store, just build an APK and install it on device
flutter build apk --obfuscate --split-debug-info=./build/app/outputs/obfuscation_symbols

Enabling workmanager debug shows notification but actual task is not run:
image

After 10 minutes it shows another notification for the same task, but again actual task is not run. Note it was a one time task. Looks like workmanager keeps on trying to run the job every 10 minutes which fails hence keeps on trying to run it forever.
image

Background plugin isolate log:

2022-06-03 19:56:02.589 29540-1486/? E/flutter: [ERROR:flutter/shell/common/shell.cc(93)] Dart Unhandled Exception:
NoSuchMethodError: No top-level getter 'Ild' declared.
  Receiver: top-level
  Tried calling: Ild, stack trace: Warning: This VM has been configured to produce stack traces that violate the Dart standard.
  *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
  pid: 29540, tid: 1486, name Unknown
  build_id: '8deece9b97153dcde758a3ce15c56eaf'
  isolate_dso_base: 7830404000, vm_dso_base: 7830404000
  isolate_instructions: 78306bc7f0, vm_instructions: 78306b8000
      #00 abs 00000078306c5eb3 virt 00000000002c1eb3 _kDartIsolateSnapshotInstructions+0x96c3
2022-06-03 19:56:02.589 29540-1486/? E/flutter: [ERROR:flutter/runtime/dart_isolate.cc(668)] Could not resolve main entrypoint function.
2022-06-03 19:56:02.589 29540-1486/? E/flutter: [ERROR:flutter/runtime/dart_isolate.cc(167)] Could not run the run main Dart entrypoint.
2022-06-03 19:56:02.592 29540-1486/? E/flutter: [ERROR:flutter/runtime/runtime_controller.cc(382)] Could not create root isolate.
2022-06-03 19:56:02.592 29540-1486/? E/flutter: [ERROR:flutter/shell/common/shell.cc(600)] Could not launch engine with configuration.

@turtlepile
Copy link

turtlepile commented Jun 3, 2022

I have the same issue, have you figured out a solution or a walkaround?

@absar
Copy link
Contributor

absar commented Jun 4, 2022

I think @ened maintains this plugin, he might have some workarounds, I haven't found any yet.
I filed an issue in dart sdk repo dart-lang/sdk#49181

@xiaoyaoking
Copy link

xiaoyaoking commented Jun 8, 2022

Had the same problem. Task does not execute.

same as your case,Generate a debug build, which works fine.

It is not only an issue with other plugins called by workmanager, rather running workmanager itself when obfuscating any App built with Flutter v2.10+. Same issue in Flutter 3, workmanager doesn't even run the call back in obfuscated Apps, which is a blocker since we are unable to release Apps with obfuscation. You can reproduce it with any obfuscated app, no need to create appbundle and upload to play store, just build an APK and install it on device flutter build apk --obfuscate --split-debug-info=./build/app/outputs/obfuscation_symbols

Enabling workmanager debug shows notification but actual task is not run: image

After 10 minutes it shows another notification for the same task, but again actual task is not run. Note it was a one time task. Looks like workmanager keeps on trying to run the job every 10 minutes which fails hence keeps on trying to run it forever. image

Background plugin isolate log:

2022-06-03 19:56:02.589 29540-1486/? E/flutter: [ERROR:flutter/shell/common/shell.cc(93)] Dart Unhandled Exception:
NoSuchMethodError: No top-level getter 'Ild' declared.
  Receiver: top-level
  Tried calling: Ild, stack trace: Warning: This VM has been configured to produce stack traces that violate the Dart standard.
  *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
  pid: 29540, tid: 1486, name Unknown
  build_id: '8deece9b97153dcde758a3ce15c56eaf'
  isolate_dso_base: 7830404000, vm_dso_base: 7830404000
  isolate_instructions: 78306bc7f0, vm_instructions: 78306b8000
      #00 abs 00000078306c5eb3 virt 00000000002c1eb3 _kDartIsolateSnapshotInstructions+0x96c3
2022-06-03 19:56:02.589 29540-1486/? E/flutter: [ERROR:flutter/runtime/dart_isolate.cc(668)] Could not resolve main entrypoint function.
2022-06-03 19:56:02.589 29540-1486/? E/flutter: [ERROR:flutter/runtime/dart_isolate.cc(167)] Could not run the run main Dart entrypoint.
2022-06-03 19:56:02.592 29540-1486/? E/flutter: [ERROR:flutter/runtime/runtime_controller.cc(382)] Could not create root isolate.
2022-06-03 19:56:02.592 29540-1486/? E/flutter: [ERROR:flutter/shell/common/shell.cc(600)] Could not launch engine with configuration.

@absar
Copy link
Contributor

absar commented Jun 15, 2022

Finally found a solution with the help of dart-lang team.

@pragma('vm:entry-point')
void bgCallback() {
  // You need below line until PR 388 is merged
  DartPluginRegistrant.ensureInitialized();
  //...
}

absar added a commit to absar/flutter_workmanager that referenced this issue Jun 15, 2022
…Manager not working when App is obfuscated or using Flutter 3.1+
ened pushed a commit that referenced this issue Jun 16, 2022
…ing when App is obfuscated or using Flutter 3.1+ (#405)
@adibpwd
Copy link

adibpwd commented Jan 2, 2024

Notif showing, but audio not

android/app/src/main/res/raw/file.mp3
playSound: true,
sound: const RawResourceAndroidNotificationSound("file"),

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants