-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
flutterLocalNotificationsPlugin.initialize block app open in release mode #2391
Comments
@Lonyless hi, did you solve the problem? |
Turns out the problem wasn’t caused by this package, but a bug in the emulator itself. Try running Android 11 to make sure |
I came across the same problem. It happens when trying to build the APK in release mode. Debug mode seems fine. In my case, however, it happend after upgrading Android Studio from Koala to Ladybug. It seems that Koala is bundled with JDK17 and Ladybug JDK21. Making Flutter use JDK17 lets me build the APK the usual way (no blocking when starting the application). Show Flutter Java version for building
Change Flutter Java version for building
By the way, I am initializing the FlutterLocalNotificationsPlugin in the main method. EDIT: Building using JDK21 with coreLibraryDesugaringEnabled, and JDK17 without coreLibraryDesugaringEnabled. |
It took me so much time to figure this out. After I rollback the
|
I'd recommend not to immediately request permissions on launch, even though it is easier. Instead, request permissions after onboarding the user a bit, and having them request or confirm notifications. For example, web browsers will block permissions requests if they don't come from a user gesture It's possible android is freaking out about this as well? I didn't actually look into it but either way I'd still recommend moving the permissions request |
@cruvie This isn't a bug but an issue with the code in your app and is actually working as expected. Since you call |
@MaikuB thanks for your response, but after I move permission request to //bug await will block the app open in release mode
await flutterLocalNotificationsPlugin.initialize(initializationSettings,
onDidReceiveNotificationResponse:
ToolLocalNotification.onDidReceiveNotificationResponse); if I remove |
@Levi-Lesches do you run the app in release mode? |
Okay, with E/flutter (13907): [ERROR:flutter/runtime/dart_vm_initializer.cc(40)] Unhandled Exception: PlatformException(invalid_icon, The resource app_icon could not be found. Please make sure it has been added as a drawable resource to your Android head project., null, null)
E/flutter (13907): #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:646)
E/flutter (13907): #1 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:334)
E/flutter (13907): <asynchronous suspension>
E/flutter (13907): #2 AndroidFlutterLocalNotificationsPlugin.initialize (package:flutter_local_notifications/src/platform_flutter_local_notifications.dart:148)
E/flutter (13907): <asynchronous suspension>
E/flutter (13907): #3 MgrLocalNotification.init (package:demo/local_notification.dart:36)
E/flutter (13907): <asynchronous suspension>
E/flutter (13907): #4 main (package:demo/main.dart:11)
E/flutter (13907): <asynchronous suspension> But I'm not sure why you're getting it because I can confirm that you have the image in the right folder. The example app works with the same |
This comment was marked as outdated.
This comment was marked as outdated.
@Levi-Lesches thanks a lot, what a relief. |
Resource shrinking being enabled is default/standard/best practices so really shouldn't be off. It's part of the optimisation process in generation release builds. There was a section the setup guide around release build configuration to ensure resources are kept through that process. Looking at the repo shared, it looks like it wasn't followed |
Good point -- I have both sections included, but I will clarify that disabled resource shrinking is a last-resort and the other method should be preferred whenever possible. |
Describe the bug
flutterLocalNotificationsPlugin.initialize block app open in release mode, but works fine in debug
To Reproduce
git clone https://github.com/cruvie/demo
flutter build apk
install build/app/outputs/flutter-apk/app-release.apk on any android platform
the app is blocked and cannot enter home page
Expected behavior
after installing can open the app with no blocking
Sample code to reproduce the problem
main.dart
local_notification.dart
flutter docker
flutter_local_notifications version
17.2.2
failed on android 14 physical or android 15 emulator
The text was updated successfully, but these errors were encountered: