首页 > 解决方案 > Firebase:NotificationCompat.Builder 错误

问题描述

我得到了一个错误,Notification.Builder我不知道为什么这是错误:

在此处输入图像描述

这是我的毕业生:

    dependencies {
    implementation 'com.google.code.gson:gson:2.8.2'
    implementation 'com.google.android.gms:play-services-gcm:16.0.0'
    implementation 'com.github.bumptech.glide:glide:3.7.0'
    implementation 'com.google.firebase:firebase-core:16.0.3'
    implementation 'com.google.firebase:firebase-iid:17.0.2'
    implementation 'com.google.firebase:firebase-messaging:17.3.2'
    implementation 'com.firebase:firebase-jobdispatcher:0.8.5'
    implementation 'com.android.support:appcompat-v7:26.1.1'
    implementation 'com.android.support:design:26.1.1'
    implementation 'com.android.support:multidex:1.0.3'
    implementation 'com.android.support:animated-vector-drawable:26.1.0'
    implementation 'com.android.support:support-v4:26.1.0'
    implementation 'com.android.support:support-compat:26.1.0'

    // [START gradle_play_config]
    implementation 'com.google.firebase:firebase-ads:15.0.1'


}

我一直在搜索,但我只发现它应该是 android 26 及更高版本,但我仍然遇到错误。

标签: javaandroidnotifications

解决方案


您的依赖项似乎没有问题。该错误只是说您传递的是 MyFirebaseMessagingService 而不是上下文。尝试:

new NotificationCompat.Builder(getContext, channelId)...

或编辑您的帖子并显示您在哪个课程中执行此操作(并写下错误,不要使用图像)。


推荐阅读