E/MethodChannel#dexterous.com/flutter/local_notifications( 7674): Failed to handle method call
[ ] E/MethodChannel#dexterous.com/flutter/local_notifications( 7674): java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.Integer.intValue()' on a null object reference
[ ] E/MethodChannel#dexterous.com/flutter/local_notifications( 7674): at com.dexterous.flutterlocalnotifications.FlutterLocalNotificationsPlugin.setSmallIcon(FlutterLocalNotificationsPlugin.java:154)
[ ] E/MethodChannel#dexterous.com/flutter/local_notifications( 7674): at com.dexterous.flutterlocalnotifications.FlutterLocalNotificationsPlugin.createNotification(FlutterLocalNotificationsPlugin.java:130)
[ ] E/MethodChannel#dexterous.com/flutter/local_notifications( 7674): at com.dexterous.flutterlocalnotifications.FlutterLocalNotificationsPlugin.showNotification(FlutterLocalNotificationsPlugin.java:576)
[ ] E/MethodChannel#dexterous.com/flutter/local_notifications( 7674): at com.dexterous.flutterlocalnotifications.FlutterLocalNotificationsPlugin.show(FlutterLocalNotificationsPlugin.java:696)
[ ] E/MethodChannel#dexterous.com/flutter/local_notifications( 7674): at com.dexterous.flutterlocalnotifications.FlutterLocalNotificationsPlugin.onMethodCall(FlutterLocalNotificationsPlugin.java:643)
[ ] E/MethodChannel#dexterous.com/flutter/local_notifications( 7674): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:201)
[ ] E/MethodChannel#dexterous.com/flutter/local_notifications( 7674): at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:88)
[ ] E/MethodChannel#dexterous.com/flutter/local_notifications( 7674): at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:202)
[ ] E/MethodChannel#dexterous.com/flutter/local_notifications( 7674): at android.os.MessageQueue.nativePollOnce(Native Method)
[ ] E/MethodChannel#dexterous.com/flutter/local_notifications( 7674): at android.os.MessageQueue.next(MessageQueue.java:326)
[ ] E/MethodChannel#dexterous.com/flutter/local_notifications( 7674): at android.os.Looper.loop(Looper.java:160)
[ ] E/MethodChannel#dexterous.com/flutter/local_notifications( 7674): at android.app.ActivityThread.main(ActivityThread.java:6669)
[ ] E/MethodChannel#dexterous.com/flutter/local_notifications( 7674): at java.lang.reflect.Method.invoke(Native Method)
[ ] E/MethodChannel#dexterous.com/flutter/local_notifications( 7674): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
[ ] E/MethodChannel#dexterous.com/flutter/local_notifications( 7674): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
[ +2 ms] E/flutter ( 7674): [ERROR:flutter/lib/ui/ui_dart_state.cc(148)] Unhandled Exception: PlatformException(error, Attempt to invoke virtual method 'int java.lang.Integer.intValue()' on a null object reference, null)
[ ] E/flutter ( 7674): #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:564:7)
[ ] E/flutter ( 7674): #1 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:302:33)
[ ] E/flutter ( 7674): <asynchronous suspension>
[ ] E/flutter ( 7674): #2 FlutterLocalNotificationsPlugin.show (package:flutter_local_notifications/src/flutter_local_notifications.dart:118:20)
[ ] E/flutter ( 7674): <asynchronous suspension>
[ ] E/flutter ( 7674): #3 _PushMessagingExampleState._showNotification (package:flutter_basf_hk_app/NotificationSample.dart:313:43)
[ ] E/flutter ( 7674): <asynchronous suspension>
[ ] E/flutter ( 7674): #4 _PushMessagingExampleState._clearTopicText (package:flutter_basf_hk_app/NotificationSample.dart:304:5)
[ ] E/flutter ( 7674): #5 _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:513:14)
[ ] E/flutter ( 7674): #6 _InkResponseState.build.<anonymous closure> (package:flutter/src/material/ink_well.dart:568:30)
[ ] E/flutter ( 7674): #7 GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:166:24)
[ ] E/flutter ( 7674): #8 TapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:246:9)
[ ] E/flutter ( 7674): #9 TapGestureRecognizer.handlePrimaryPointer (package:flutter/src/gestures/tap.dart:175:7)
[ ] E/flutter ( 7674): #10 PrimaryPointerGestureRecognizer.handleEvent (package:flutter/src/gestures/recognizer.dart:436:9)
[ ] E/flutter ( 7674): #11 PointerRouter._dispatch (package:flutter/src/gestures/pointer_router.dart:73:12)
[ ] E/flutter ( 7674): #12 PointerRouter.route (package:flutter/src/gestures/pointer_router.dart:101:11)
[ ] E/flutter ( 7674): #13 _WidgetsFlutterBinding&BindingBase&GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:214:19)
[ ] E/flutter ( 7674): #14 _WidgetsFlutterBinding&BindingBase&GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:192:22)
[ ] E/flutter ( 7674): #15 _WidgetsFlutterBinding&BindingBase&GestureBinding._handlePointerEvent (package:flutter/src/gestures/binding.dart:149:7)
[ ] E/flutter ( 7674): #16 _WidgetsFlutterBinding&BindingBase&GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:101:7)
[ ] E/flutter ( 7674): #17 _WidgetsFlutterBinding&BindingBase&GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:85:7)
[ ] E/flutter ( 7674): #18 _rootRunUnary (dart:async/zone.dart:1136:13)
[ ] E/flutter ( 7674): #19 _CustomZone.runUnary (dart:async/zone.dart:1029:19)
[ ] E/flutter ( 7674): #20 _CustomZone.runUnaryGuarded (dart:async/zone.dart:931:7)
[ ] E/flutter ( 7674): #21 _invoke1 (dart:ui/hooks.dart:223:10)
[ ] E/flutter ( 7674): #22 _dispatchPointerDataPacket (dart:ui/hooks.dart:144:5)
flutter_local_notifications: 0.6.0
not show notification
Code
```
FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin =
FlutterLocalNotificationsPlugin();
@override
void initState() {
super.initState();
var initializationSettingsAndroid =
AndroidInitializationSettings('app_icon');
var initializationSettingsIOS = IOSInitializationSettings(
onDidReceiveLocalNotification: onDidRecieveLocalNotification);
var initializationSettings = InitializationSettings(
initializationSettingsAndroid, initializationSettingsIOS);
flutterLocalNotificationsPlugin.initialize(initializationSettings,
onSelectNotification: onSelectNotification);
}
Future
var androidPlatformChannelSpecifics =
AndroidNotificationDetails('100', 'DLite', 'DLite');
var iOSPlatformChannelSpecifics = IOSNotificationDetails();
var platformChannelSpecifics = NotificationDetails(
androidPlatformChannelSpecifics, iOSPlatformChannelSpecifics);
await flutterLocalNotificationsPlugin.show(
100, title, message, platformChannelSpecifics);
}
```
cannot reproduce your problem. if you could fork the repo and update the example app code to reproduce the problem then that would be great. having said that, the stack trace implies an issue with setting the notification icon. have you added and configured the resource properly?
ok found solution changed app_icon name
I had the same issue and this is how I solved it: (These steps briefly elaborate the solution @dhaval0122 mentions above).
If you're using Android Studio right click on res folder in main directory > Select new > Image Asset.
Change Icon type to 'Notification Icons'.
Set whatever clip art, image you want to set and give it a name copy the name and pass that name to AndroidInitializationSettings('app_icon') in place of 'app_icon'. This will stop the crash because now the app has a legit icon for the notifications.
Make sure to stop and rerun the app completely to apply the changes.
@MaikuB I would suggest adding a note about this in the README.md. It seems like it's a fairly common issue that's easily resolvable by following this final response.
Cheers!
Most helpful comment
I had the same issue and this is how I solved it: (These steps briefly elaborate the solution @dhaval0122 mentions above).
If you're using Android Studio right click on res folder in main directory > Select new > Image Asset.
Change Icon type to 'Notification Icons'.
Set whatever clip art, image you want to set and give it a name copy the name and pass that name to
AndroidInitializationSettings('app_icon')in place of 'app_icon'. This will stop the crash because now the app has a legit icon for the notifications.Make sure to stop and rerun the app completely to apply the changes.