利用flutter编写移动的应用程序代码
Future _showNotificationRequest() async {
var androidPlatformChannelSpecifics = new AndroidNotificationDetails(
'your channel id', 'your channel name', 'your channel description',
playSound: true,
importance: Importance.Max,
priority: Priority.High,
ticker: 'ticker');
var iOSPlatformChannelSpecifics =
new IOSNotificationDetails(presentSound: false);
var platformChannelSpecifics = new NotificationDetails(
androidPlatformChannelSpecifics, iOSPlatformChannelSpecifics);
await flutterLocalNotificationsPlugin.show(
0,
'Новые заявки',
'Обновите список заявок',
platformChannelSpecifics,
payload: 'No_Sound',
);
}
在版本31上更改SDK后,因为Google Play不发布我的应用
compileSdkVersion 31
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "kz.vashdomofon.ksu"
minSdkVersion 22
targetSdkVersion 31
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
执行此方法时出错
D/CompatibilityChangeReporter(29530): Compat change id reported: 160794467; UID 10146; state: ENABLED
E/MethodChannel#dexterous.com/flutter/local_notifications(29530): Failed to handle method call
E/MethodChannel#dexterous.com/flutter/local_notifications(29530): java.lang.IllegalArgumentException: kz.vashdomofon.ksu: Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent.
E/MethodChannel#dexterous.com/flutter/local_notifications(29530): Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE if some functionality depends on the PendingIntent being mutable, e.g. if it needs to be used with inline replies or bubbles.
E/MethodChannel#dexterous.com/flutter/local_notifications(29530): at android.app.PendingIntent.checkFlags(PendingIntent.java:375)
E/MethodChannel#dexterous.com/flutter/local_notifications(29530): at android.app.PendingIntent.getActivityAsUser(PendingIntent.java:458)
E/MethodChannel#dexterous.com/flutter/local_notifications(29530): at android.app.PendingIntent.getActivity(PendingIntent.java:444)
E/MethodChannel#dexterous.com/flutter/local_notifications(29530): at android.app.PendingIntent.getActivity(PendingIntent.java:408)
E/MethodChannel#dexterous.com/flutter/local_notifications(29530): at com.dexterous.flutterlocalnotifications.FlutterLocalNotificationsPlugin.createNotification(FlutterLocalNotificationsPlugin.java:134)
E/MethodChannel#dexterous.com/flutter/local_notifications(29530): at com.dexterous.flutterlocalnotifications.FlutterLocalNotificationsPlugin.showNotification(FlutterLocalNotificationsPlugin.java:688)
E/MethodChannel#dexterous.com/flutter/local_notifications(29530): at com.dexterous.flutterlocalnotifications.FlutterLocalNotificationsPlugin.show(FlutterLocalNotificationsPlugin.java:827)
E/MethodChannel#dexterous.com/flutter/local_notifications(29530): at com.dexterous.flutterlocalnotifications.FlutterLocalNotificationsPlugin.onMethodCall(FlutterLocalNotificationsPlugin.java:750)
E/MethodChannel#dexterous.com/flutter/local_notifications(29530): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:233)
E/MethodChannel#dexterous.com/flutter/local_notifications(29530): at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:84)
E/MethodChannel#dexterous.com/flutter/local_notifications(29530): at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:865)
E/MethodChannel#dexterous.com/flutter/local_notifications(29530): at android.os.MessageQueue.nativePollOnce(Native Method)
E/MethodChannel#dexterous.com/flutter/local_notifications(29530): at android.os.MessageQueue.next(MessageQueue.java:335)
E/MethodChannel#dexterous.com/flutter/local_notifications(29530): at android.os.Looper.loopOnce(Looper.java:161)
E/MethodChannel#dexterous.com/flutter/local_notifications(29530): at android.os.Looper.loop(Looper.java:288)
E/MethodChannel#dexterous.com/flutter/local_notifications(29530): at android.app.ActivityThread.main(ActivityThread.java:7839)
E/MethodChannel#dexterous.com/flutter/local_notifications(29530): at java.lang.reflect.Method.invoke(Native Method)
E/MethodChannel#dexterous.com/flutter/local_notifications(29530): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
E/MethodChannel#dexterous.com/flutter/local_notifications(29530): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
E/MethodChannel#dexterous.com/flutter/local_notifications(29530): Failed to handle method call
E/MethodChannel#dexterous.com/flutter/local_notifications(29530): java.lang.IllegalArgumentException: kz.vashdomofon.ksu: Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent.
E/MethodChannel#dexterous.com/flutter/local_notifications(29530): Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE if some functionality depends on the PendingIntent being mutable, e.g. if it needs to be used with inline replies or bubbles.
E/MethodChannel#dexterous.com/flutter/local_notifications(29530): at android.app.PendingIntent.checkFlags(PendingIntent.java:375)
E/MethodChannel#dexterous.com/flutter/local_notifications(29530): at android.app.PendingIntent.getActivityAsUser(PendingIntent.java:458)
E/MethodChannel#dexterous.com/flutter/local_notifications(29530): at android.app.PendingIntent.getActivity(PendingIntent.java:444)
E/MethodChannel#dexterous.com/flutter/local_notifications(29530): at android.app.PendingIntent.getActivity(PendingIntent.java:408)
E/MethodChannel#dexterous.com/flutter/local_notifications(29530): at com.dexterous.flutterlocalnotifications.FlutterLocalNotificationsPlugin.createNotification(FlutterLocalNotificationsPlugin.java:134)
E/MethodChannel#dexterous.com/flutter/local_notifications(29530): at com.dexterous.flutterlocalnotifications.FlutterLocalNotificationsPlugin.showNotification(FlutterLocalNotificationsPlugin.java:688)
E/MethodChannel#dexterous.com/flutter/local_notifications(29530): at com.dexterous.flutterlocalnotifications.FlutterLocalNotificationsPlugin.show(FlutterLocalNotificationsPlugin.java:827)
E/MethodChannel#dexterous.com/flutter/local_notifications(29530): at com.dexterous.flutterlocalnotifications.FlutterLocalNotificationsPlugin.onMethodCall(FlutterLocalNotificationsPlugin.java:750)
E/MethodChannel#dexterous.com/flutter/local_notifications(29530): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:233)
E/MethodChannel#dexterous.com/flutter/local_notifications(29530): at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:84)
E/MethodChannel#dexterous.com/flutter/local_notifications(29530): at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:865)
E/MethodChannel#dexterous.com/flutter/local_notifications(29530): at android.os.MessageQueue.nativePollOnce(Native Method)
E/MethodChannel#dexterous.com/flutter/local_notifications(29530): at android.os.MessageQueue.next(MessageQueue.java:335)
E/MethodChannel#dexterous.com/flutter/local_notifications(29530): at android.os.Looper.loopOnce(Looper.java:161)
E/MethodChannel#dexterous.com/flutter/local_notifications(29530): at android.os.Looper.loop(Looper.java:288)
E/MethodChannel#dexterous.com/flutter/local_notifications(29530): at android.app.ActivityThread.main(ActivityThread.java:7839)
E/MethodChannel#dexterous.com/flutter/local_notifications(29530): at java.lang.reflect.Method.invoke(Native Method)
E/MethodChannel#dexterous.com/flutter/local_notifications(29530): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
E/MethodChannel#dexterous.com/flutter/local_notifications(29530): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
E/flutter (29530): [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: PlatformException(error, kz.vashdomofon.ksu: Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent.
E/flutter (29530): Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE if some functionality depends on the PendingIntent being mutable, e.g. if it needs to be used with inline replies or bubbles., null, java.lang.IllegalArgumentException: kz.vashdomofon.ksu: Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent.
E/flutter (29530): Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE if some functionality depends on the PendingIntent being mutable, e.g. if it needs to be used with inline replies or bubbles.
E/flutter (29530): at android.app.PendingIntent.checkFlags(PendingIntent.java:375)
E/flutter (29530): at android.app.PendingIntent.getActivityAsUser(PendingIntent.java:458)
E/flutter (29530): at android.app.PendingIntent.getActivity(PendingIntent.java:444)
E/flutter (29530): at android.app.PendingIntent.getActivity(PendingIntent.java:408)
E/flutter (29530): at com.dexterous.flutterlocalnotifications.FlutterLocalNotificationsPlugin.createNotification(FlutterLocalNotificationsPlugin.java:134)
E/flutter (29530): at com.dexterous.flutterlocalnotifications.FlutterLocalNotificationsPlugin.showNotification(FlutterLocalNotificationsPlugin.java:688)
E/flutter (29530): at com.dexterous.flutterlocalnotifications.FlutterLocalNotificationsPlugin.show(FlutterLocalNotificationsPlugin.java:827)
E/flutter (29530): at com.dexterous.flutterlocalnotifications.FlutterLocalNotificationsPlugin.onMethodCall(FlutterLocalNotificationsPlugin.java:750)
E/flutter (29530): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:233)
E/flutter (29530): at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:84)
E/flutter (29530): at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:865)
E/flutter (29530): at android.os.MessageQueue.nativePollOnce(Native Method)
E/flutter (29530): at android.os.MessageQueue.next(MessageQueue.java:335)
E/flutter (29530): at android.os.Looper.loopOnce(Looper.java:161)
E/flutter (29530): at android.os.Looper.loop(Looper.java:288)
E/flutter (29530): at android.app.ActivityThread.main(ActivityThread.java:7839)
E/flutter (29530): at java.lang.reflect.Method.invoke(Native Method)
E/flutter (29530): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
E/flutter (29530): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
E/flutter (29530): )
E/flutter (29530): #0 StandardMethodCodec.decodeEnvelope
E/flutter (29530): #1 MethodChannel._invokeMethod
E/flutter (29530): <asynchronous suspension>
E/flutter (29530): #2 FlutterLocalNotificationsPlugin.show
E/flutter (29530): <asynchronous suspension>
E/flutter (29530): #3 _KSU._showNotificationRequest
E/flutter (29530): <asynchronous suspension>
E/flutter (29530):
E/flutter (29530): [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: PlatformException(error, kz.vashdomofon.ksu: Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent.
E/flutter (29530): Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE if some functionality depends on the PendingIntent being mutable, e.g. if it needs to be used with inline replies or bubbles., null, java.lang.IllegalArgumentException: kz.vashdomofon.ksu: Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent.
E/flutter (29530): Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE if some functionality depends on the PendingIntent being mutable, e.g. if it needs to be used with inline replies or bubbles.
E/flutter (29530): at android.app.PendingIntent.checkFlags(PendingIntent.java:375)
E/flutter (29530): at android.app.PendingIntent.getActivityAsUser(PendingIntent.java:458)
E/flutter (29530): at android.app.PendingIntent.getActivity(PendingIntent.java:444)
E/flutter (29530): at android.app.PendingIntent.getActivity(PendingIntent.java:408)
E/flutter (29530): at com.dexterous.flutterlocalnotifications.FlutterLocalNotificationsPlugin.createNotification(FlutterLocalNotificationsPlugin.java:134)
E/flutter (29530): at com.dexterous.flutterlocalnotifications.FlutterLocalNotificationsPlugin.showNotification(FlutterLocalNotificationsPlugin.java:688)
E/flutter (29530): at com.dexterous.flutterlocalnotifications.FlutterLocalNotificationsPlugin.show(FlutterLocalNotificationsPlugin.java:827)
E/flutter (29530): at com.dexterous.flutterlocalnotifications.FlutterLocalNotificationsPlugin.onMethodCall(FlutterLocalNotificationsPlugin.java:750)
E/flutter (29530): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:233)
E/flutter (29530): at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:84)
E/flutter (29530): at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:865)
E/flutter (29530): at android.os.MessageQueue.nativePollOnce(Native Method)
E/flutter (29530): at android.os.MessageQueue.next(MessageQueue.java:335)
E/flutter (29530): at android.os.Looper.loopOnce(Looper.java:161)
E/flutter (29530): at android.os.Looper.loop(Looper.java:288)
E/flutter (29530): at android.app.ActivityThread.main(ActivityThread.java:7839)
E/flutter (29530): at java.lang.reflect.Method.invoke(Native Method)
E/flutter (29530): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
E/flutter (29530): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
E/flutter (29530): )
E/flutter (29530): #0 StandardMethodCodec.decodeEnvelope
E/flutter (29530): #1 MethodChannel._invokeMethod
E/flutter (29530): <asynchronous suspension>
E/flutter (29530): #2 FlutterLocalNotificationsPlugin.show
E/flutter (29530): <asynchronous suspension>
E/flutter (29530): #3 _KSU._showNotificationPPR
E/flutter (29530): <asynchronous suspension>
我没有找到如何修复这个错误,或者解决方案不适合我的情况。有人能告诉我在哪里找吗?
我尝试在MainActivity.kt中添加FLAG_MUTABLE或FALG_IMMUTABLE,但意图超出方法范围
1条答案
按热度按时间bzzcjhmw1#
通过改进Flutter、 Package 和分级解决问题