Android 不兼容类型:FirebaseMessagingService无法转换为上下文

Android 不兼容类型:FirebaseMessagingService无法转换为上下文,android,firebase,gradle,firebase-mlkit,Android,Firebase,Gradle,Firebase Mlkit,我正在尝试在我的应用程序中实现ML-Kit:Natural-Language API和ML-Kit:Language-Identification模型,我已经实现了所有设置,它工作正常,但当我尝试实现这些设置时 com.google.firebase:firebase-ml-natural-language:22.0.0 com.google.firebase:firebase-ml-natural-language-language-id-model:20.0.7 FirebaseMessa

我正在尝试在我的应用程序中实现ML-Kit:Natural-Language API和ML-Kit:Language-Identification模型,我已经实现了所有设置,它工作正常,但当我尝试实现这些设置时

com.google.firebase:firebase-ml-natural-language:22.0.0
com.google.firebase:firebase-ml-natural-language-language-id-model:20.0.7
FirebaseMessagingService类它给了我一个错误,它根本找不到,它说它不能转换成上下文对象。如果删除库,则错误消失

日志:

D:\project\uumoo\u android\app\src\main\java\net\uumoo\pocket\android\Services\myfirebasemsagingservice.java:66: 错误:不兼容的类型:MyFirebaseMessagingService不能为 转换为上下文

这是我的应用程序gradle

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
//noinspection GradleCompatible
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:support-v4:27.1.1'
implementation 'com.android.support:support-vector-drawable:27.1.1'
implementation 'com.google.android.gms:play-services-maps:15.0.1'
implementation 'com.google.firebase:firebase-messaging:17.3.0'
implementation 'com.firebase:firebase-jobdispatcher:0.8.5'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.android.support:design:27.1.1'
implementation 'de.hdodenhof:circleimageview:2.2.0'
implementation 'com.android.support:cardview-v7:27.1.1'
implementation 'com.wdullaer:materialdatetimepicker:3.6.2'
implementation 'com.dlazaro66.qrcodereaderview:qrcodereaderview:2.0.3'
implementation 'com.github.ittianyu:BottomNavigationViewEx:1.2.4'
//implementation 'com.squareup.retrofit2:retrofit:2.2.0'
//implementation 'com.google.code.gson:gson:2.8.2'
//implementation 'com.squareup.retrofit2:converter-gson:2.2.0'
implementation 'com.android.volley:volley:1.1.1'


implementation 'com.jakewharton:butterknife:8.8.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
implementation 'com.google.android.gms:play-services-location:15.0.1'
implementation 'com.github.bumptech.glide:glide:4.7.1'
annotationProcessor 'com.github.bumptech.glide:compiler:4.7.1'
implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'com.github.tozny:java-aes-crypto:1.1.0'
implementation 'com.scottyab:aescrypt:0.0.1'
implementation 'com.kbeanie:multipicker:1.5@aar'
implementation "android.arch.persistence.room:runtime:1.1.1"
annotationProcessor "android.arch.persistence.room:compiler:1.1.1"
implementation 'com.androidadvance:topsnackbar:1.1.1'
implementation 'com.github.delight-im:Android-AdvancedWebView:v3.0.0'
implementation 'com.github.XuDaojie:QRCode-Android:v0.4.2'
implementation 'com.google.firebase:firebase-ml-vision:18.0.1'
implementation 'com.github.zomato:androidphotofilters:1.0.1'
implementation 'com.yakivmospan:scytale:1.0.1'
implementation 'com.xw.repo:bubbleseekbar:3.19'
implementation 'com.google.maps.android:android-maps-utils:0.5+'

// barcode reader library only use for UI
implementation 'info.androidhive:barcode-reader:1.1.5'

implementation "com.google.code.gson:gson:$rootProject.gsonVersion"

implementation 'com.google.android.gms:play-services-auth:16.0.1'
implementation 'com.google.android.gms:play-services-auth-api-phone:16.0.0'

//implementation 'com.google.firebase:firebase-core:17.2.1'
//dentify the language of text with ML Kit
implementation 'com.google.firebase:firebase-ml-natural-language:22.0.0'
  implementation 'com.google.firebase:firebase-ml-natural-language-language-id-model:20.0.7'
}
apply plugin: 'com.google.gms.google-services'
这是我的项目gradle

dependencies {
    classpath 'com.android.tools.build:gradle:3.1.4'

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
    classpath 'com.google.gms:google-services:3.2.0'
    // new
   // classpath 'com.google.gms:google-services:4.3.2'  // Google Services plugin
}

我刚刚降低了firebase核心的等级,它又能工作了

 // @see https://stackoverflow.com/a/53371918/3152877
// ##################### Firebase Core ###########################
implementation 'com.google.firebase:firebase-core:16.0.6'

// @see https://stackoverflow.com/a/53371918/3152877
//###################### FCM ####################################
implementation 'com.google.firebase:firebase-messaging:17.3.2'

// ################### MAP ######################################
implementation 'com.google.android.gms:play-services-maps:15.0.1'

//#################### identify the language of text with ML Kit################
implementation 'com.google.firebase:firebase-ml-natural-language:18.2.0'
implementation 'com.google.firebase:firebase-ml-natural-language-language-id-model:18.0.2'

显然,在MyFirebaseMessagingService的某个地方,您正试图将“this”作为上下文传递。向我们展示您的服务。@ror问题已更新。是的,我用过这个。在我使用降级版本之前,它可以正常工作,而不是再次工作
 // @see https://stackoverflow.com/a/53371918/3152877
// ##################### Firebase Core ###########################
implementation 'com.google.firebase:firebase-core:16.0.6'

// @see https://stackoverflow.com/a/53371918/3152877
//###################### FCM ####################################
implementation 'com.google.firebase:firebase-messaging:17.3.2'

// ################### MAP ######################################
implementation 'com.google.android.gms:play-services-maps:15.0.1'

//#################### identify the language of text with ML Kit################
implementation 'com.google.firebase:firebase-ml-natural-language:18.2.0'
implementation 'com.google.firebase:firebase-ml-natural-language-language-id-model:18.0.2'