我试图在Oreo版本中使用Firebase显示通知,因此当我获得解决方案时它不显示
NotificationCompat.Builder(这个,CHANNEL_ID),但它显示我像这个
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’所以你必须改变你的支持库的版本号.