I am trying to implement ML Kit: Natural Language APIs and ML Kit: Language Identification Model in my application, I had implemented all settings and it works fine, but when I try to implement those.
com.google.firebase:firebase-ml-natural-language:22.0.0
com.google.firebase:firebase-ml-natural-language-language-id-model:20.0.7
FirebaseMessagingService class it gives me an error and it can't find it at all, It says it can't convert into a Context object. if remove the library the error gone.
Logcat:
D:\project\uumoo_android\app\src\main\java\net\uumoo\pocket\android\Services\MyFirebaseMessagingService.java:66: error: incompatible types: MyFirebaseMessagingService cannot be converted to Context
private Context context = MyFirebaseMessagingService.this;
This is my app 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'
this is my project 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
}
I just downgrade the firebase-core .It works again
// @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'