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
Background isolate throws No top-level getter 'xxx' declared
when app is obfuscated
#49181
Comments
//cc @aam |
Had the same problem. Turn off obfuscation The problem still exists. |
This is working as intended and ultimately has nothing to do with with obfuscation. If you try your code on master channel of Flutter you will discover that it does not work either even without obfuscation. As it stands now to fix things you need to annotate @pragma('vm:entry-point')
void bgCallback() {
// ...
} The underlying problem is that We have a problem on our hands - plugins that use /cc @bkonyi @rmacnak-google @goderbauer @chinmaygarde @Hixie |
Thank you very much mraleph it works with |
When app is obfuscated background isolates run by
flutter_workmanager
throwDart Unhandled Exception: NoSuchMethodError: No top-level getter 'xxx' declared
in Flutter 2.10 and 3. However it works fine without obfuscation in both Flutter 2.10 and 3. It also works with obfuscation in Flutter 2.8.Steps to reproduce:
workmanager: ^0.5.0
dependency inpubspec.yaml
main.dart
Code
Build the app with obfuscation using:
flutter build apk --obfuscate --split-debug-info=./build/app/outputs/obfuscation_symbols
This will generate the APK
Install
app-release.apk
on a physical Android device or a 64bit emulatorRun the App and press
Run BG tasks
, this should schedule a one time Android workmanager job, which should ideally runbgCallback
, you will see in the notification that workmanager is trying to run the callbackExpected result is to run
bgCallback
, but you can see in logcat, it will throwDart Unhandled Exception: NoSuchMethodError: No top-level getter 'xxx' declared.
Complete Logcat
Environment:
The text was updated successfully, but these errors were encountered: