Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

App crashed on chinease, janpease and korean script for google_mlkit_text_recognition: ^0.14.0 in google_ml_kit: ^0.19.0 #707

Closed
ubaidakmal opened this issue Oct 21, 2024 · 2 comments
Labels
close-inactivity stale Text Recognition Issues corresponding to Text Recognition API

Comments

@ubaidakmal
Copy link

Describe your issue. If applicable, add screenshots to help explain your problem.

when i tried to recognize the Chinese script my app crashed

this is crash

D/skia (27146): SkJpegCodec::onGetPixels -
E/AndroidRuntime(27146): FATAL EXCEPTION: main
E/AndroidRuntime(27146): Process: com.aq.barcode.scanner.qrcode.scanner.creator, PID: 27146
E/AndroidRuntime(27146): java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/mlkit/vision/text/chinese/ChineseTextRecognizerOptions$Builder;
E/AndroidRuntime(27146): at com.google_mlkit_text_recognition.TextRecognizer.initialize(TextRecognizer.java:64)
E/AndroidRuntime(27146): at com.google_mlkit_text_recognition.TextRecognizer.handleDetection(TextRecognizer.java:87)
E/AndroidRuntime(27146): at com.google_mlkit_text_recognition.TextRecognizer.onMethodCall(TextRecognizer.java:43)
E/AndroidRuntime(27146): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:267)
E/AndroidRuntime(27146): at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:292)
E/AndroidRuntime(27146): at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$io-flutter-embedding-engine-dart-DartMessenger(DartMessenger.java:319)
E/AndroidRuntime(27146): at io.flutter.embedding.engine.dart.DartMessenger$$ExternalSyntheticLambda0.run(Unknown Source:12)
E/AndroidRuntime(27146): at android.os.Handler.handleCallback(Handler.java:942)
E/AndroidRuntime(27146): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(27146): at android.os.Looper.loopOnce(Looper.java:204)
E/AndroidRuntime(27146): at android.os.Looper.loop(Looper.java:291)
E/AndroidRuntime(27146): at android.app.ActivityThread.main(ActivityThread.java:8134)
E/AndroidRuntime(27146): at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(27146): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:601)
E/AndroidRuntime(27146): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1019)
E/AndroidRuntime(27146): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.mlkit.vision.text.chinese.ChineseTextRecognizerOptions$Builder" on path: DexPathList[[zip file "/data/app/~~JF9cZ3TXYHCy4JUoz489dQ==/com.aq.barcode.scanner.qrcode.scanner.creator-_vRPY-cdYXdsIhzONpAoGw==/base.apk"],nativeLibraryDirectories=[/data/app/~~JF9cZ3TXYHCy4JUoz489dQ==/com.aq.barcode.scanner.qrcode.scanner.creator-_vRPY-cdYXdsIhzONpAoGw==/lib/arm64, /data/app/~~JF9cZ3TXYHCy4JUoz489dQ==/com.aq.barcode.scanner.qrcode.scanner.creator-_vRPY-cdYXdsIhzONpAoGw==/base.apk!/lib/arm64-v8a, /system/lib64, /system_ext/lib64]]
E/AndroidRuntime(27146): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:259)
E/AndroidRuntime(27146): at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
E/AndroidRuntime(27146): at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
E/AndroidRuntime(27146): ... 15 more
I/ExceptionHandle(27146): at com.google_mlkit_text_recognition.TextRecognizer.initialize(TextRecognizer.java:64)
I/ExceptionHandle(27146): at com.google_mlkit_text_recognition.TextRecognizer.handleDetection(TextRecognizer.java:87)
I/ExceptionHandle(27146): at com.google_mlkit_text_recognition.TextRecognizer.onMethodCall(TextRecognizer.java:43)
I/ExceptionHandle(27146): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:267)
I/ExceptionHandle(27146): at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:292)
I/ExceptionHandle(27146): at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$io-flutter-embedding-engine-dart-DartMessenger(DartMessenger.java:319)
I/ExceptionHandle(27146): at io.flutter.embedding.engine.dart.DartMessenger$$ExternalSyntheticLambda0.run(Unknown Source:12)
I/ExceptionHandle(27146): at android.os.Handler.handleCallback(Handler.java:942)
I/ExceptionHandle(27146): at android.os.Handler.dispatchMessage(Handler.java:99)
I/ExceptionHandle(27146): at android.os.Looper.loopOnce(Looper.java:204)
I/ExceptionHandle(27146): at android.os.Looper.loop(Looper.java:291)
I/ExceptionHandle(27146): at android.app.ActivityThread.main(ActivityThread.java:8134)
I/ExceptionHandle(27146): at java.lang.reflect.Method.invoke(Native Method)
I/ExceptionHandle(27146): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:601)
I/ExceptionHandle(27146): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1019)

Steps to reproduce.

Future _getImageAndConvertToText(BuildContext context, ImageSource imgSource) async {
// Pick an image
final XFile? pickedFile = await _picker.pickImage(source: imgSource);
if (pickedFile == null) return;

final croppedFile = await ImageCropper().cropImage(
  sourcePath: pickedFile.path,
  aspectRatioPresets: [
    CropAspectRatioPreset.square,
    CropAspectRatioPreset.ratio3x2,
    CropAspectRatioPreset.original,
    CropAspectRatioPreset.ratio4x3,
    CropAspectRatioPreset.ratio16x9
  ],
  uiSettings: [
    AndroidUiSettings(
      toolbarTitle: 'Easy Scan',
      toolbarColor: AppColors.appColor,
      toolbarWidgetColor: Colors.white,
      initAspectRatio: CropAspectRatioPreset.original,
      lockAspectRatio: false,
    ),
    IOSUiSettings(title: 'Cropper'),
    WebUiSettings(context: context),
  ],
);

if (croppedFile != null) {
  showSubscriptionScreen = false;
  final inputImage = InputImage.fromFilePath(croppedFile.path);

  // List of supported scripts
  final List<TextRecognitionScript> supportedScripts = [
    TextRecognitionScript.latin,
    // TextRecognitionScript.chinese,
    TextRecognitionScript.japanese,
    TextRecognitionScript.korean,
    TextRecognitionScript.devanagiri,
  ];

  TextRecognizer? textRecognizer;
  RecognizedText? recognizedText;

  for (var script in supportedScripts) {
    textRecognizer = TextRecognizer(script: script);
    try {
      recognizedText = await textRecognizer.processImage(inputImage);
      if (recognizedText.text.isNotEmpty) {
        break; // Exit loop when valid text is found
      }
    } catch (e) {
      recognizedText = null;
    } finally {
      await textRecognizer.close();
    }
  }

  if (recognizedText == null || recognizedText.text.isEmpty) {
    // Show snackbar if no supported language is found
    ScaffoldMessenger.of(context).showSnackBar(
      SnackBar(content: Text("Language is not supported")),
    );
    return;
  }

  // If text is found, navigate to ImageToTextScreen with recognized text
  showSubscriptionScreen = false;
  Navigator.push(
    context,
    MaterialPageRoute(
      builder: (context) => ImageToTextScreen(
        value: recognizedText!.text,
        xFile: pickedFile,
      ),
    ),
  ).then((_) {
    Navigator.pop(context);
  });
} else {
  print('Cropping cancelled');
}

}

What is the expected result?

D/skia (27146): SkJpegCodec::onGetPixels -
E/AndroidRuntime(27146): FATAL EXCEPTION: main
E/AndroidRuntime(27146): Process: com.aq.barcode.scanner.qrcode.scanner.creator, PID: 27146
E/AndroidRuntime(27146): java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/mlkit/vision/text/chinese/ChineseTextRecognizerOptions$Builder;
E/AndroidRuntime(27146): at com.google_mlkit_text_recognition.TextRecognizer.initialize(TextRecognizer.java:64)
E/AndroidRuntime(27146): at com.google_mlkit_text_recognition.TextRecognizer.handleDetection(TextRecognizer.java:87)
E/AndroidRuntime(27146): at com.google_mlkit_text_recognition.TextRecognizer.onMethodCall(TextRecognizer.java:43)
E/AndroidRuntime(27146): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:267)
E/AndroidRuntime(27146): at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:292)
E/AndroidRuntime(27146): at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$io-flutter-embedding-engine-dart-DartMessenger(DartMessenger.java:319)
E/AndroidRuntime(27146): at io.flutter.embedding.engine.dart.DartMessenger$$ExternalSyntheticLambda0.run(Unknown Source:12)
E/AndroidRuntime(27146): at android.os.Handler.handleCallback(Handler.java:942)
E/AndroidRuntime(27146): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(27146): at android.os.Looper.loopOnce(Looper.java:204)
E/AndroidRuntime(27146): at android.os.Looper.loop(Looper.java:291)
E/AndroidRuntime(27146): at android.app.ActivityThread.main(ActivityThread.java:8134)
E/AndroidRuntime(27146): at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(27146): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:601)
E/AndroidRuntime(27146): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1019)
E/AndroidRuntime(27146): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.mlkit.vision.text.chinese.ChineseTextRecognizerOptions$Builder" on path: DexPathList[[zip file "/data/app/~~JF9cZ3TXYHCy4JUoz489dQ==/com.aq.barcode.scanner.qrcode.scanner.creator-_vRPY-cdYXdsIhzONpAoGw==/base.apk"],nativeLibraryDirectories=[/data/app/~~JF9cZ3TXYHCy4JUoz489dQ==/com.aq.barcode.scanner.qrcode.scanner.creator-_vRPY-cdYXdsIhzONpAoGw==/lib/arm64, /data/app/~~JF9cZ3TXYHCy4JUoz489dQ==/com.aq.barcode.scanner.qrcode.scanner.creator-_vRPY-cdYXdsIhzONpAoGw==/base.apk!/lib/arm64-v8a, /system/lib64, /system_ext/lib64]]
E/AndroidRuntime(27146): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:259)
E/AndroidRuntime(27146): at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
E/AndroidRuntime(27146): at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
E/AndroidRuntime(27146): ... 15 more
I/ExceptionHandle(27146): at com.google_mlkit_text_recognition.TextRecognizer.initialize(TextRecognizer.java:64)
I/ExceptionHandle(27146): at com.google_mlkit_text_recognition.TextRecognizer.handleDetection(TextRecognizer.java:87)
I/ExceptionHandle(27146): at com.google_mlkit_text_recognition.TextRecognizer.onMethodCall(TextRecognizer.java:43)
I/ExceptionHandle(27146): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:267)
I/ExceptionHandle(27146): at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:292)
I/ExceptionHandle(27146): at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$io-flutter-embedding-engine-dart-DartMessenger(DartMessenger.java:319)
I/ExceptionHandle(27146): at io.flutter.embedding.engine.dart.DartMessenger$$ExternalSyntheticLambda0.run(Unknown Source:12)
I/ExceptionHandle(27146): at android.os.Handler.handleCallback(Handler.java:942)
I/ExceptionHandle(27146): at android.os.Handler.dispatchMessage(Handler.java:99)
I/ExceptionHandle(27146): at android.os.Looper.loopOnce(Looper.java:204)
I/ExceptionHandle(27146): at android.os.Looper.loop(Looper.java:291)
I/ExceptionHandle(27146): at android.app.ActivityThread.main(ActivityThread.java:8134)
I/ExceptionHandle(27146): at java.lang.reflect.Method.invoke(Native Method)
I/ExceptionHandle(27146): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:601)
I/ExceptionHandle(27146): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1019)

Did you try our example app?

No

Is it reproducible in the example app?

No

Reproducible in which OS?

Android

Flutter/Dart Version?

3.19.3

Plugin Version?

google_ml_kit: ^0.19.0

@ubaidakmal ubaidakmal changed the title App crashed on chinease script App crashed on chinease, janpease and korean script for google_mlkit_text_recognition: ^0.14.0 in google_ml_kit: ^0.19.0 Oct 21, 2024
@bensonarafat bensonarafat added the Text Recognition Issues corresponding to Text Recognition API label Oct 23, 2024
Copy link

This issue is stale because it has been open for 30 days with no activity.

@github-actions github-actions bot added the stale label Nov 23, 2024
Copy link

github-actions bot commented Dec 8, 2024

This issue was closed because it has been inactive for 14 days since being marked as stale.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Dec 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
close-inactivity stale Text Recognition Issues corresponding to Text Recognition API
Projects
None yet
Development

No branches or pull requests

2 participants