Salik
Salik

Reputation: 1

Android ML Kit - Compilation Error with getSymbols() Method in Text.Element

I'm implementing text recognition in my Android app using Google's ML Kit. However, I've encountered a compilation error related to the getSymbols() method in the Text.Element class. I have included all the necessary imports, and according to the ML Kit documentation, the method should be available.

https://developers.google.com/android/reference/com/google/mlkit/vision/text/Text.Element#getSymbols()

// ...
for (Text.Element element: line.getElements()) {
    // ...
    for (Text.Symbol symbol: element.getSymbols()) {
        // Access symbol properties here...
    }
}
// ...

The exact error message is:

error: cannot find symbol
for (Text.Symbol symbol: element.getSymbols()) {
                                            ^
  symbol:   method getSymbols()
  location: variable element of type Element

I expected the element.getSymbols() to work as per the documentation, which indicates that getSymbols() should return an unmodifiable list of Text.Symbol objects.

What could be causing this error, and how can I resolve it?

Upvotes: 0

Views: 116

Answers (1)

Martin Zeitler
Martin Zeitler

Reputation: 76807

Since there is limited information about the setup or which version it even is, I can only hint for, that the com.google.android.gms version may require one meta-data node:

<application>

    <!-- android:value="ocr,ocr_chinese,ocr_devanagari,ocr_japanese,ocr_korean,..." -->
   <meta-data
       android:name="com.google.mlkit.vision.DEPENDENCIES"
       android:value="ocr"/>
 
</application>

My suspicion is, that it doesn't have any OCR module.

https://developers.google.com/ml-kit/vision/text-recognition/v2/android#before_you_begin

Upvotes: 0

Related Questions