Search code examples
androidfirebasefirebase-mlkit

Cannot resolve symbol FirebaseVisionTextDetector


I get Cannot resolve symbol FirebaseVisionTextDetector error when I put in my module:

import com.google.firebase.ml.vision.text.FirebaseVisionTextDetector;

I can't understand why because in gradle I have the correct implementation:

implementation 'com.google.firebase:firebase-ml-vision:18.0.1'

SOLVED

I have solved by downgrading to 16.0.0. Still don't know the reason why.

implementation 'com.google.firebase:firebase-ml-vision:16.0.0'

Solution

  • Downgrade is not really a solution. There are many bug fixes and upgrades which you should ship with your app.

    FirebaseVisionTextDetector class was removed in firebase-ml-vision:17.0.0 , it was last available in firebase-ml-vision:16.0.0 they have changed it to FirebaseVisionTextRecognizer.

    There are not much difference between both classes. So go ahead and do changes.

    Changes to make:

    Before (v-16.0.0):

    FirebaseVisionTextDetector
    FirebaseVisionTextDetector.detectInImage(image)
    List<FirebaseVisionText.Block> resultsBlocks = results.getBlocks();
    for (FirebaseVisionText.Block block : resultsBlocks) {
                for (FirebaseVisionText.Line line : block.getLines()) {
                    //...
                }
            }
    

    After (v-18.0.1):

    FirebaseVisionTextRecognizer
    FirebaseVisionTextDetector.processImage(image)
    List<FirebaseVisionText.TextBlock> blocks = results.getTextBlocks();
        for (FirebaseVisionText.TextBlock block : blocks) {
             // ...
            }
        }
    

    You can clone Official ML kit sample project to see complete code implementation.