繁体   English   中英

不能使用 flutter_local_notifications

[英]Can't use flutter_local_notifications

我在我的项目中使用最新版本的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)

我的flutter版

Flutter 1.22.6 • channel stable 

pubspec.yaml

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

在此处输入图像描述

我终于重现了此类问题,可以通过升级或降级插件或从.pub_chace 中删除插件并安装它来解决它,在你的情况下flutter_local_notifications

打开 android\build.gradle 找到这个

子项目 { 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"
        }
    }
}

删除 project.configurations.all 及其所有内容

新代码现在看起来像这样

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

flutter 清洁 flutter 发布

暂无
暂无

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM