Search code examples
androidfirebaseandroid-studiofirebase-mlkitgoogle-mlkit

why my app can’t use FirebaseVisionLabelDetectorOptions class


I tried to make an object from FirebaseVisionLabelDetectorOptions class but my app doesn’t import it I got this error . And this is my dependencies

implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'com.google.firebase:firebase-analytics:17.2.2'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.google.firebase:firebase-database:19.3.0'
implementation 'com.wonderkiln:camerakit:0.13.1'
implementation 'com.github.d-max:spots-dialog:1.1@aar'
implementation 'com.google.firebase:firebase-core:16.0.5'
implementation 'com.google.firebase:firebase-ml-vision:18.0.1'
implementation 'com.google.firebase:firebase-ml-vision-image-label-model:17.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'com.google.firebase:firebase-ml-vision:24.0.3'

Solution

  • You are using the Cloud Landmarks API so you will need the Cloud Options class

    FirebaseVisionCloudDetectorOptions options =
        new FirebaseVisionCloudDetectorOptions.Builder()
                .setModelType(FirebaseVisionCloudDetectorOptions.LATEST_MODEL)
                .setMaxResults(15)
                .build();
    

    The Cloud based APIs work differently to on-device ones, so the options will be slightly different.