android – NotificationCompat.Builder(getApplicationContext(),CHANNEL_ID)无法处理Oreo Firebase通知

前端之家收集整理的这篇文章主要介绍了android – NotificationCompat.Builder(getApplicationContext(),CHANNEL_ID)无法处理Oreo Firebase通知前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我试图在Oreo版本中使用Firebase显示通知,因此当我获得解决方案时它不显示
NotificationCompat.Builder(这个,CHANNEL_ID),但它显示我像这个

我的build.gradle文件

apply plugin: 'com.android.application'

    dependencies {
    compile project(':library')
    compile project(':camerafragment')
    compile 'com.google.android.gms:play-services:11.0.0'
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'com.mcxiaoke.volley:library:1.0.17'
    compile 'com.android.support:appcompat-v7:26.0.0-alpha1'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    compile 'com.android.support:recyclerview-v7:26.0.0-alpha1'
    compile 'com.android.support:cardview-v7:26.0.0-alpha1'
    compile 'com.google.firebase:firebase-messaging:11.0.0'
    compile 'com.google.android.gms:play-services-maps:11.0.0'
    compile 'com.facebook.android:facebook-android-sdk:[4,5)'
    compile 'com.android.support:design:26.0.0-alpha1'
    compile 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1'
    compile 'com.jakewharton:butterknife:7.0.1'
    compile 'com.google.android.gms:play-services-auth:11.0.0'
    compile 'net.gotev:uploadservice:2.1'
    compile 'com.google.firebase:firebase-auth:11.0.0'
    compile 'com.google.code.gson:gson:2.8.0'
    compile 'com.android.support:support-v4:26.0.0-alpha1'
    }

    android {

    compileSdkVersion 27
    buildToolsVersion "27.0.0"
    dexOptions {
        javaMaxHeapSize "4g"
    }
    defaultConfig {
        applicationId "com.trashmap"
        minSdkVersion 17
        targetSdkVersion 27

        // Enabling multidex support.
        multiDexEnabled true
        versionCode 17
        versionName "1.16"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
           // shrinkResources true//new add to reduce size
            proguardFiles getDefaultProguardFile('proguard-android.txt'),'proguard-rules.pro'
        }

    }



      sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src']
            res.srcDirs = ['res']
        }
    }
}

apply plugin: 'com.google.gms.google-services'

解决方法

NotificationCompat.Builder (Context context)

This constructor was deprecated in API level 26.1.0.

use NotificationCompat.Builder(Context,String) instead. All posted Notifications must specify a NotificationChannel Id.

你已经定义了编译’com.android.support:support-v4:26.0.0-alpha1’所以你必须改变你的支持库的版本号.

原文链接:https://www.f2er.com/android/309397.html

猜你在找的Android相关文章