简体   繁体   English

不能使用 flutter_local_notifications

[英]Can't use flutter_local_notifications

I using the latest version of flutter_local_notifications in my project, but keep getting this issue我在我的项目中使用最新版本的flutter_local_notifications ,但一直遇到这个问题

Launching lib/main.dart on Mi A2 in debug mode...
/home/xxx/Desktop/flutter_linux_1.22.6-stable/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_local_notifications-4.0.1+1/android/src/main/java/com/dexterous/flutterlocalnotifications/FlutterLocalNotificationsPlugin.java:1260: error: cannot find symbol
            List<NotificationChannel> channels = notificationManagerCompat.getNotificationChannels();
                                                                          ^
  symbol:   method getNotificationChannels()
  location: variable notificationManagerCompat of type NotificationManagerCompat
1 error

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':flutter_local_notifications:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 25s
Exception: Gradle task assembleDebug failed with exit code 1
Exited (sigterm)

My flutter version我的flutter版

Flutter 1.22.6 • channel stable 

pubspec.yaml pubspec.yaml

firebase_messaging: ^9.0.0
firebase_core: ^1.0.0
flutter_local_notifications: ^4.0.1+1

在此处输入图像描述

I finally reproduced such kind of issue and could solve it by upgrading or downgrading the plugin or remove the plugin from.pub_chace and install it, in your case flutter_local_notifications .我终于重现了此类问题,可以通过升级或降级插件或从.pub_chace 中删除插件并安装它来解决它,在你的情况下flutter_local_notifications

open android\build.gradle find this打开 android\build.gradle 找到这个

subprojects { project.evaluationDependsOn(':app')子项目 { project.evaluationDependsOn(':app')

project.configurations.all {
    resolutionStrategy.eachDependency { details ->
        if (details.requested.group == 'androidx.core' &&
                !details.requested.name.contains('androidx')) {
            details.useVersion "1.0.1"
        }
    }
}

delete project.configurations.all and all its content删除 project.configurations.all 及其所有内容

the new code now looks like this新代码现在看起来像这样

subprojects { project.evaluationDependsOn(':app') }

flutter clean flutter pub get flutter 清洁 flutter 发布

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 flutter_local_notifications 事件不起作用 - flutter_local_notifications events doesn't work 计划通知未显示(Flutter_local_notifications) - scheduled notifications not showing (Flutter_local_notifications) flutter_local_notifications onNotificationReceived 方法 - Flutter - flutter_local_notifications onNotificationReceived method - Flutter flutter_local_notifications 对我不起作用 - flutter_local_notifications not working for me flutter_local_notifications 路由全屏 - flutter_local_notifications route fullscreen 使用 flutter_local_notifications 安排通知 - Schedule notification using flutter_local_notifications 在 flutter_local_notifications 上禁用振动 - Disable vibration on flutter_local_notifications 在 Xcode 中找不到模块“flutter_local_notifications” - Module 'flutter_local_notifications' not found in Xcode 在 Flutter 中,我们如何使用 Firebase Messaging onBackgroundMessage 创建通知,使用 flutter_local_notifications? - In Flutter, how do we use Firebase Messaging onBackgroundMessage to create a notification, using flutter_local_notifications? Flutter:应用程序终止时,flutter_local_notifications onSelectNotification 不起作用 - Flutter : flutter_local_notifications onSelectNotification not working when app is terninated
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM