googlesamples / mlkit

A collection of sample apps to demonstrate how to use Google's ML Kit APIs on Android and iOS
Apache License 2.0
3.57k stars 2.93k forks source link

[Bug report] DigitalInk: No implementation found DigitalInkRecognizerJni.initNativeRecognizer #809

Closed vknow360 closed 6 months ago

vknow360 commented 6 months ago

First of all I am not android developer directly. I create extensions for AI2.

Since I can't add native libs to apk via compiler so I use Apk Tool to inject native libs. After compiling and installing, I am able to download model and unzip it successfully.

04-18 07:51:27.266 14724 14724 D DigitalInk: en
04-18 07:51:27.267 14724 14724 I MddModelManager: download(): Download for model RemoteModel{modelName=digital_ink_recognition_model_com.google.mlkit.vision.digitalink.DigitalInkRecognitionModelIdentifier@4f0e77bf, baseModel=null, modelType=DIGITAL_INK}
04-18 07:51:27.291 14724 17807 D TransportRuntime.SQLiteEventStore: Storing event with priority=VERY_LOW, name=FIREBASE_ML_SDK for destination cct
04-18 07:51:27.294 14724 17807 D TransportRuntime.JobInfoScheduler: Upload for context TransportContext(cct, VERY_LOW, MSRodHRwczovL2ZpcmViYXNlbG9nZ2luZy5nb29nbGVhcGlzLmNvbS92MGNjL2xvZy9iYXRjaD9mb3JtYXQ9anNvbl9wcm90bzNc) is already scheduled. Returning...
04-18 07:51:27.310 14724 17824 D OffroadFileDownloader: Data download scheduled for file: https://dl.google.com/handwriting/models/qrnn.en.reco_20200318.fst_20191208.recospec.zip
04-18 07:51:27.311 14724 17810 D zzxs    : Starting download: https://dl.google.com/handwriting/models/qrnn.en.reco_20200318.fst_20191208.recospec.zip
04-18 07:51:27.311 14724 17810 V zzxs    : Is http uri, downloading (uri: https://dl.google.com/handwriting/models/qrnn.en.reco_20200318.fst_20191208.recospec.zip)
04-18 07:51:27.313 14724 17824 D OffroadFileDownloader: Data download scheduled for file: https://dl.google.com/handwriting/models/indy_lstm.latin.6x216.tflite.20191208.zip
04-18 07:51:27.313 14724 17824 D OffroadFileDownloader: Data download scheduled for file: https://dl.google.com/handwriting/models/en.20191208.compact.fst.zip
04-18 07:51:27.314 14724 17914 D zzxs    : Starting download: https://dl.google.com/handwriting/models/indy_lstm.latin.6x216.tflite.20191208.zip
04-18 07:51:27.314 14724 17914 V zzxs    : Is http uri, downloading (uri: https://dl.google.com/handwriting/models/indy_lstm.latin.6x216.tflite.20191208.zip)
04-18 07:51:27.940 14724 17810 D DownloadCompleteHandler: Downloaded file datadownloadfile_1713361832931_6c7afaf3d49b457796555bfe1defa87a7a84dff1
04-18 07:51:27.943 14724 17935 D zzxs    : Starting download: https://dl.google.com/handwriting/models/en.20191208.compact.fst.zip
04-18 07:51:27.943 14724 17935 V zzxs    : Is http uri, downloading (uri: https://dl.google.com/handwriting/models/en.20191208.compact.fst.zip)
04-18 07:51:36.497 14724 17914 D DownloadCompleteHandler: Downloaded file datadownloadfile_1713361832791_27cfb1b5a7e5a4dee7ba6c07aaea9c3343b34ee4
04-18 07:51:51.162 14724 17935 D DownloadCompleteHandler: Downloaded file datadownloadfile_1713361832932_e658bab006ee49265531934194b332cc0ddd6c7d
04-18 07:51:51.498 14724 17932 I MddModelManager: download: complete
04-18 07:51:51.498 14724 17932 I MddModelManager: download: returned with status 1

But while initializing recognizer, this error occurs.

04-18 07:52:04.681 14724 18011 I MddModelManager: getDownloadedFilesForModel()
04-18 07:52:04.691 14724 17932 I MddModelManager: getDownloadedFilesForModel(): started
04-18 07:52:04.691 14724 17932 I MddModelManager: getDownloadedFilesForModel(): acquired result.
04-18 07:52:04.694 14724 18011 E w360.DigitalInk: No implementation found for long com.google.mlkit.vision.digitalink.internal.DigitalInkRecognizerJni.initNativeRecognizer(java.io.FileInputStream, java.io.FileInputStream, java.io.FileInputStream) (tried Java_com_google_mlkit_vision_digitalink_internal_DigitalInkRecognizerJni_initNativeRecognizer and Java_com_google_mlkit_vision_digitalink_internal_DigitalInkRecognizerJni_initNativeRecognizer__Ljava_io_FileInputStream_2Ljava_io_FileInputStream_2Ljava_io_FileInputStream_2) - is the library loaded, e.g. System.loadLibrary?

Initialize code:

public void Initialize(){
    inkBuilder = new Ink.Builder();
    // Specify the recognition model for a language
    DigitalInkRecognitionModelIdentifier modelIdentifier = null;
    try {
      modelIdentifier =
              DigitalInkRecognitionModelIdentifier.fromLanguageTag(DigitalInkRecognitionModelIdentifier.EN.getLanguageTag());
    } catch (MlKitException e) {
      // language tag failed to parse, handle error.
    }
    if (modelIdentifier != null) {
      DigitalInkRecognitionModel model =
              DigitalInkRecognitionModel.builder(modelIdentifier).build();

// Get a recognizer for the language
      recognizer =
              DigitalInkRecognition.getClient(
                      DigitalInkRecognizerOptions.builder(model).build());
      isInitialized = true;
    }
  }
vknow360 commented 6 months ago

Sorry, my mistake.