Android ML Kit - Text.Element 中的 getSymbols() 方法出现编译错误

问题描述 投票:0回答:1

我正在使用 Google 的 ML Kit 在我的 Android 应用程序中实现文本识别。但是,我遇到了与 Text.Element 类中的 getSymbols() 方法相关的编译错误。我已经包含了所有必要的导入,并且根据 ML Kit 文档,该方法应该可用。

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...
    }
}
// ...

确切的错误消息是:

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

我期望 element.getSymbols() 按照文档工作,这表明 getSymbols() 应该返回不可修改的 Text.Symbol 对象列表。

什么可能导致此错误,如何解决?

java android android-studio google-mlkit text-recognition
1个回答
0
投票

由于有关设置或版本的信息有限,我只能提示,

com.google.android.gms
版本需要一个
meta-data
节点,因为它加载模块的方式不同:

<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>
© www.soinside.com 2019 - 2024. All rights reserved.