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

Contextual Actions must contain a valid icon? #2268

Open
tj1334311578 opened this issue Mar 15, 2024 · 4 comments
Open

Contextual Actions must contain a valid icon? #2268

tj1334311578 opened this issue Mar 15, 2024 · 4 comments

Comments

@tj1334311578
Copy link

PlatformException(error, Contextual Actions must contain a valid icon, null, java.lang.NullPointerException: Contextual Actions must contain a valid icon
D/StaticsAgent(27908): at android.app.Notification$Action$Builder.checkContextualActionNullFields(Notification.java:2092)
D/StaticsAgent(27908): at android.app.Notification$Action$Builder.build(Notification.java:2108)
D/StaticsAgent(27908): at androidx.core.app.NotificationCompatBuilder$Api20Impl.build(NotificationCompatBuilder.java:645)
D/StaticsAgent(27908): at androidx.core.app.NotificationCompatBuilder.addAction(NotificationCompatBuilder.java:408)
D/StaticsAgent(27908): at androidx.core.app.NotificationCompatBuilder.(NotificationCompatBuilder.java:112)
D/StaticsAgent(27908): at androidx.core.app.NotificationCompat$Builder.build(NotificationCompat.java:2550)
D/StaticsAgent(27908): at com.dexterous.flutterlocalnotifications.FlutterLocalNotificationsPlugin.createNotification(FlutterLocalNotificationsPlugin.java:419)
D/StaticsAgent(27908): at com.dexterous.flutterlocalnotifications.FlutterLocalNotificationsPlugin.showNotification(FlutterLocalNotificationsPlugin.java:1248)
D/StaticsAgent(27908): at com.dexterous.flutterlocalnotifications.FlutterLocalNotificationsPlugin.show(FlutterLocalNotificationsPlugin.java:1588)
D/StaticsAgent(27908): at com.dexterous.flutterlocalnotifications.FlutterLocalNotificationsPlugin.onMethodCall(FlutterLocalNotificationsPlugin.java:1413)
D/StaticsAgent(27908): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:267)
D/StaticsAgent(27908): at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:292)
D/StaticsAgent(27908): at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$io-flutter-embedding-engine-dart-DartMessenger(DartMessenger.java:319)
D/StaticsAgent(27908): at io.flutter.embedding.engine.dart.DartMessenger$$ExternalSyntheticLambda0.run(Unknown Source:12)
D/StaticsAgent(27908): at android.os.Handler.handleCallback(Handler.java:942)
D/StaticsAgent(27908): at android.os.Handler.dispatchMessage(Handler.java:99)
D/StaticsAgent(27908): at android.os.Looper.loopOnce(Looper.java:201)
D/StaticsAgent(27908): at android.os.Looper.loop(Looper.java:288)
D/StaticsAgent(27908): at android.app.ActivityThread.main(ActivityThread.java:7884)
D/StaticsAgent(27908): at java.lang.reflect.Method.invoke(Native Method)
D/StaticsAgent(27908): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
D/StaticsAgent(27908): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)
D/StaticsAgent(27908): )
D/StaticsAgent(27908): stack:#0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:651:7)
D/StaticsAgent(27908): #1 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:334:18)
D/StaticsAgent(27908):
D/StaticsAgent(27908): #2 FlutterLocalNotificationsPlugin.show (package:flutter_local_notifications/src/flutter_local_notifications_plugin.dart:240:7)
D/StaticsAgent(27908):
D/StaticsAgent(27908): #3 NotificationUtil._showNotificationWithNoSound (package:project_speed/app/utils/notification_util.dart:235:5)
D/StaticsAgent(27908):
D/StaticsAgent(27908): #4 NotificationUtil.startNotification (package:project_speed/app/utils/notification_util.dart:198:5)
D/StaticsAgent(27908):

@tj1334311578
Copy link
Author

I initialized it and printed out the corresponding resource id. The call showed a crash.

@tj1334311578
Copy link
Author

参见打印日志:E/initialize: default id:( 4130): 2131165263

@tj1334311578
Copy link
Author

log:E/MethodChannel#dexterous.com/flutter/local_notifications( 4130): Failed to handle method call
E/MethodChannel#dexterous.com/flutter/local_notifications( 4130): java.lang.NullPointerException: Contextual Actions must contain a valid icon
E/MethodChannel#dexterous.com/flutter/local_notifications( 4130): at android.app.Notification$Action$Builder.checkContextualActionNullFields(Notification.java:2092)
E/MethodChannel#dexterous.com/flutter/local_notifications( 4130): at android.app.Notification$Action$Builder.build(Notification.java:2108)
E/MethodChannel#dexterous.com/flutter/local_notifications( 4130): at androidx.core.app.NotificationCompatBuilder$Api20Impl.build(NotificationCompatBuilder.java:645)
E/MethodChannel#dexterous.com/flutter/local_notifications( 4130): at androidx.core.app.NotificationCompatBuilder.addAction(NotificationCompatBuilder.java:408)
E/MethodChannel#dexterous.com/flutter/local_notifications( 4130): at androidx.core.app.NotificationCompatBuilder.(NotificationCompatBuilder.java:112)
E/MethodChannel#dexterous.com/flutter/local_notifications( 4130): at androidx.core.app.NotificationCompat$Builder.build(NotificationCompat.java:2550)
E/MethodChannel#dexterous.com/flutter/local_notifications( 4130): at com.dexterous.flutterlocalnotifications.FlutterLocalNotificationsPlugin.createNotification(FlutterLocalNotificationsPlugin.java:419)
E/MethodChannel#dexterous.com/flutter/local_notifications( 4130): at com.dexterous.flutterlocalnotifications.FlutterLocalNotificationsPlugin.showNotification(FlutterLocalNotificationsPlugin.java:1249)
E/MethodChannel#dexterous.com/flutter/local_notifications( 4130): at com.dexterous.flutterlocalnotifications.FlutterLocalNotificationsPlugin.show(FlutterLocalNotificationsPlugin.java:1589)
E/MethodChannel#dexterous.com/flutter/local_notifications( 4130): at com.dexterous.flutterlocalnotifications.FlutterLocalNotificationsPlugin.onMethodCall(FlutterLocalNotificationsPlugin.java:1414)
E/MethodChannel#dexterous.com/flutter/local_notifications( 4130): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:267)
E/MethodChannel#dexterous.com/flutter/local_notifications( 4130): at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:292)
E/MethodChannel#dexterous.com/flutter/local_notifications( 4130): at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$io-flutter-embedding-engine-dart-DartMessenger(DartMessenger.java:319)
E/MethodChannel#dexterous.com/flutter/local_notifications( 4130): at io.flutter.embedding.engine.dart.DartMessenger$$ExternalSyntheticLambda0.run(Unknown Source:12)
E/MethodChannel#dexterous.com/flutter/local_notifications( 4130): at android.os.Handler.handleCallback(Handler.java:942)
E/MethodChannel#dexterous.com/flutter/local_notifications( 4130): at android.os.Handler.dispatchMessage(Handler.java:99)
E/MethodChannel#dexterous.com/flutter/local_notifications( 4130): at android.os.Looper.loopOnce(Looper.java:201)
E/MethodChannel#dexterous.com/flutter/local_notifications( 4130): at android.os.Looper.loop(Looper.java:288)
E/MethodChannel#dexterous.com/flutter/local_notifications( 4130): at android.app.ActivityThread.main(ActivityThread.java:7884)
E/MethodChannel#dexterous.com/flutter/local_notifications( 4130): at java.lang.reflect.Method.invoke(Native Method)
E/MethodChannel#dexterous.com/flutter/local_notifications( 4130): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
E/MethodChannel#dexterous.com/flutter/local_notifications( 4130): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)
I/flutter ( 4130): TAG v ——animation:false false false
I/flutter ( 4130): TAG v object>>> 1.2825396825396826 1.1857142857142857
I/flutter ( 4130): TAG v =====crash:=======
I/flutter ( 4130): PlatformException(error, Contextual Actions must contain a valid icon, null, java.lang.NullPointerException: Contextual Actions must contain a valid icon
I/flutter ( 4130): at android.app.Notification$Action$Builder.checkContextualActionNullFields(Notification.java:2092)
I/flutter ( 4130): at android.app.Notification$Action$Builder.build(Notification.java:2108)
I/flutter ( 4130): at androidx.core.app.NotificationCompatBuilder$Api20Impl.build(NotificationCompatBuilder.java:645)
I/flutter ( 4130): at androidx.core.app.NotificationCompatBuilder.addAction(Notific
I/flutter ( 4130): TAG v ationCompatBuilder.java:408)
I/flutter ( 4130): at androidx.core.app.NotificationCompatBuilder.(NotificationCompatBuilder.java:112)
I/flutter ( 4130): at androidx.core.app.NotificationCompat$Builder.build(NotificationCompat.java:2550)
I/flutter ( 4130): at com.dexterous.flutterlocalnotifications.FlutterLocalNotificationsPlugin.createNotification(FlutterLocalNotificationsPlugin.java:419)
I/flutter ( 4130): at com.dexterous.flutterlocalnotifications.FlutterLocalNotificationsPlugin.showNotification(FlutterLocalNotificationsPlugin.java:1249)
I/flutter ( 4130): at com.dexterous.flutterlocalnoti
I/flutter ( 4130): TAG v fications.FlutterLocalNotificationsPlugin.show(FlutterLocalNotificationsPlugin.java:1589)
I/flutter ( 4130): at com.dexterous.flutterlocalnotifications.FlutterLocalNotificationsPlugin.onMethodCall(FlutterLocalNotificationsPlugin.java:1414)
I/flutter ( 4130): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:267)
I/flutter ( 4130): at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:292)
I/flutter ( 4130): at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$io-flutter-embe
I/flutter ( 4130): TAG v dding-engine-dart-DartMessenger(DartMessenger.java:319)
I/flutter ( 4130): at io.flutter.embedding.engine.dart.DartMessenger$$ExternalSyntheticLambda0.run(Unknown Source:12)
I/flutter ( 4130): at android.os.Handler.handleCallback(Handler.java:942)
I/flutter ( 4130): at android.os.Handler.dispatchMessage(Handler.java:99)
I/flutter ( 4130): at android.os.Looper.loopOnce(Looper.java:201)
I/flutter ( 4130): at android.os.Looper.loop(Looper.java:288)
I/flutter ( 4130): at android.app.ActivityThread.main(ActivityThread.java:7884)
I/flutter ( 4130): at java.lang.reflect.Method.invoke(Native Method)
I/flutter ( 4130): at com.android.internal.os.RuntimeInit
I/flutter ( 4130): TAG v $MethodAndArgsCaller.run(RuntimeInit.java:548)
I/flutter ( 4130): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)
I/flutter ( 4130): )
I/flutter ( 4130): #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:651:7)
I/flutter ( 4130): #1 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:334:18)
I/flutter ( 4130):
I/flutter ( 4130): #2 FlutterLocalNotificationsPlugin.show (package:flutter_local_notifications/src/flutter_local_notifications_plugin.dart:240:7)
I/flutter ( 4130):
I/flutter ( 4130): #3 Notific
I/flutter ( 4130): TAG v ationUtil._showNotificationWithNoSound (package:project_speed/app/utils/notification_util.dart:235:5)
I/flutter ( 4130):
I/flutter ( 4130): #4 NotificationUtil.startNotification (package:project_speed/app/utils/notification_util.dart:198:5)
I/flutter ( 4130):

@MaikuB
Copy link
Owner

MaikuB commented May 1, 2024

I'm not sure what issue you're trying to describe here. The exception tells you the problem that contextual actions (emphasis on context actions) need an icon. That it's being thrown means you haven't provided one. My assumption is you think the default icon used for initialisation is to related to this and it's not as that is for the notification action

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

No branches or pull requests

2 participants