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] No valid text recognizer #544

Closed HosseinDevPro closed 2 years ago

HosseinDevPro commented 2 years ago

Describe the bug I'm using the bundled version of google MLKit OCR library It works correctly in debug mode but when I got a release version with DexGuard it raised the below error:

ErrorMessage:

07-10 17:13:31.214 32482 9863 E native : E0710 17:13:31.214593 9863 jni_helper.cc:619] No valid text recognizer: initialize the OCR engine before use, and make sure it has not been shut down.

I set the below rule for DexGuard(Version 9.3.11) but it shows an error again.

` -keepclasseswithmembers class com.google.android.gms. { *; } -keepclasseswithmembers enum com.google.android.gms.* { ; } -keepclasseswithmembers interface com.google.android.gms. { *; }

-keepclasseswithmembers class com.google.mlkit. { *; } -keepclasseswithmembers enum com.google.mlkit.* { ; } -keepclasseswithmembers interface com.google.mlkit. { *; } ` Is there any way to figure out which class must be kept?

SDK Info:

Also got below new error in latest version of com.google.mlkit:text-recognition:16.0.0-beta4 :

07-10 18:36:12.601 15404 16735 E native : E0000 00:00:1657461972.601107 16735 validated_graph_config.cc:878] INTERNAL: RET_CHECK failure (third_ party/mediapipe/framework/validated_graph_config.cc:878) iter != stream_to_producer_.end() Unable to find upstream edge for back edge "ocr_result" (shouldn't have passed validation). 07-10 18:36:12.601 15404 16735 E native : Stack trace: 07-10 18:36:12.601 15404 16735 E native : 07-10 18:36:12.601 15404 16735 E native : E0000 00:00:1657461972.601323 16735 pipeline_jni.cc:96] INTERNAL: RET_CHECK failure (third_party/media pipe/framework/validated_graph_config.cc:878) iter != stream_to_producer_.end() Unable to find upstream edge for back edge "ocr_result" (shouldn't have passed validation). 07-10 18:36:12.601 15404 16735 E native : === Source Location Trace: === 07-10 18:36:12.601 15404 16735 E native : third_party/mediapipe/framework/validated_graph_config.cc:878 07-10 18:36:12.601 15404 16735 E native : third_party/mediapipe/framework/validated_graph_config.cc:429 07-10 18:36:12.601 15404 16735 E native : third_party/mediapipe/framework/calculator_graph.cc:448 07-10 18:36:12.601 15404 16735 E native : photos/vision/visionkit/pipeline/scheduler.cc:781 07-10 18:36:12.601 15404 16735 E native :

vedopar commented 2 years ago

For com.google.mlkit:text-recognition:16.0.0-beta4, does it work in debug mode only or fail regardless?

vedopar commented 2 years ago

Could you share the full log please?

HosseinDevPro commented 2 years ago

@vedopar , Yes it works in debug mode. It was fixed by this DexGuard rules: -keepresourcefiles assets/mlkit*/**