android - 错误:类 Builder 中的构造函数 Builder 不能应用于给定类型;
问题描述
我在应用程序中集成了 FCM 通知。我收到错误:类 Builder 中的构造函数 Builder 不能应用于给定类型。在 NotificationCompat 构造函数中我只传递一个参数。如果我传递两个参数,我得到了上述错误。
我得到了 FCM 令牌和消息正文,但是当我在 build.gradle 中的代码下方注释时,FCM 未显示在通知栏上,然后我在 NotificationCompat 构造函数中传递了两个参数,但我收到错误其他 java 文件,如无法解析 getSupportManger、getActionBar(类文件android.support.v7.app.ActionBarActivity not found)请检查下面的代码
> buildscript { > repositories { > google() > jcenter() > } > dependencies { > classpath 'com.google.gms:google-services:4.1.0' > classpath 'com.android.tools.build:gradle:3.3.2' > classpath 'com.github.dcendents:android-maven-gradle-plugin:2.0' > }} allprojects { > repositories { > google() > jcenter() > }} task clean(type: Delete) { delete rootProject.buildDir } subprojects { > project.configurations.all { > resolutionStrategy.eachDependency { details -> > if (details.requested.group == 'com.android.support' > && !details.requested.name.contains('multidex') ) { > details.useVersion "25.3.1" > } } > } } > > showNotification Method public void showNotification(String > title,String message){ > NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this,"") > .setContentTitle("abc") > .setSmallIcon(R.drawable.abc_logo) > .setAutoCancel(true) > .setContentText(message); > NotificationManagerCompat manager= >NotificationManagerCompat.from(this,"MyNotification");//error here >manager.notify(999,notificationBuilder.build()); }
当我在 gradle 文件中评论 subProject 部分时,我在 Notification Compact 构造函数中传递了两个参数,但在其他 java 文件中出现错误,例如(找不到 android.support.v7.app.ActionBarActivity 的类文件)。我已经在 Notification Compact 构造函数中传递了一个参数,但是我收到了 fcm 消息,但没有在通知栏上显示通知,所以我该怎么办
解决方案
推荐阅读
- html - CSS overflow-x: hidden 使某些元素在移动设备上上下移动
- unit-testing - 模拟器中firebase规则的简单单元测试总是失败
- ios - 使用多个平台分发 xcframework 的 Pod 验证失败
- azure - 如何使用 databricks 将一个 azure 数据湖容器中的所有内容传输到另一个容器?
- lambda - Lambda Calculus 中的pair/vireo 访问如何工作?
- regex - 正则表达式忽略字符串中的字母数字字符
- c# - C# Discord webhook,发送图像并将文本放在该图像上
- android - 在 ViewPager2 中禁用以下项目
- amazon-web-services - 如何覆盖 Amplify 登录页面
- intellij-idea - 如何从非 Java 扩展(如 .conf 文件)导航到 Java 类声明?