eliasteeny / flutter_document_scanner

Document scanner plugin ported from react native to flutter
MIT License
38 stars 26 forks source link

Android Crash in release. #18

Open CarlosVallsCiscar opened 2 years ago

CarlosVallsCiscar commented 2 years ago

In debug mode the plugin works well, but in release mode the app crash with this error from Crashlytics:

Fatal Exception: java.lang.UnsatisfiedLinkError: No implementation found for java.lang.String m.b.b.a.d() (tried Java_m_b_b_a_d and Java_m_b_b_a_d__)
       at org.opencv.core.Core.getBuildInformation_0(Core.java)
       at org.opencv.core.Core.getBuildInformation(Core.java)
       at org.opencv.android.StaticHelper.initOpenCV(StaticHelper.java:2)
       at org.opencv.android.OpenCVLoader.initDebug(OpenCVLoader.java:1)
       at com.example.document_scanner.views.OpenNoteCameraView.initOpenCv(OpenNoteCameraView.java:1)
       at com.example.document_scanner.views.MainView.<init>(MainView.java:36)
       at com.example.document_scanner.views.MainView.createInstance(MainView.java:2)
       at com.example.document_scanner.DocumentScannerViewManager.getView(DocumentScannerViewManager.java:4)
       at io.flutter.plugin.platform.SingleViewPresentation.onCreate(SingleViewPresentation.java:129)
       at android.app.Dialog.dispatchOnCreate(Dialog.java:403)
       at android.app.Dialog.show(Dialog.java:302)
       at android.app.Presentation.show(Presentation.java:249)
       at io.flutter.plugin.platform.VirtualDisplayController.<init>(VirtualDisplayController.java:55)
       at io.flutter.plugin.platform.VirtualDisplayController.create(VirtualDisplayController.java:65)
       at io.flutter.plugin.platform.PlatformViewsController$1.createVirtualDisplayForPlatformView(PlatformViewsController.java:110)
       at io.flutter.embedding.engine.systemchannels.PlatformViewsChannel$1.create(PlatformViewsChannel.java:14)
       at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.a(MethodChannel.java:17)
       at io.flutter.embedding.engine.dart.DartMessenger.e(DartMessenger.java:17)
       at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:4)
       at android.os.MessageQueue.nativePollOnce(MessageQueue.java)
       at android.os.MessageQueue.next(MessageQueue.java:325)
       at android.os.Looper.loop(Looper.java:142)
       at android.app.ActivityThread.main(ActivityThread.java:6602)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:442)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:857)

Modifying build.gradle for the app disabling minify and shrink and now works, but the app size is bigger. Changes:

minifyEnabled false
shrinkResources false

Any ideas??, i check the other issues and no one has related problems.

Flutter doctor:

[✓] Flutter (Channel stable, 2.5.1, on macOS 11.6 20G165 darwin-x64, locale es-ES)
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
[✓] Xcode - develop for iOS and macOS
[✓] Chrome - develop for the web
[✓] Android Studio (version 2020.3)
[✓] IntelliJ IDEA Ultimate Edition (version 2021.2.2)
[✓] VS Code (version 1.60.0)
[✓] Connected device (2 available)

• No issues found!

Edit:

Crashlytics receive another error:

Fatal Exception: java.lang.RuntimeException: getParameters failed (empty parameters)
       at android.hardware.Camera.native_getParameters(Camera.java)
       at android.hardware.Camera.getParameters(Camera.java:2199)
       at com.example.document_scanner.views.OpenNoteCameraView.onPreviewFrame(OpenNoteCameraView.java:509)
       at android.hardware.Camera$EventHandler.handleMessage(Camera.java:1288)
       at android.os.Handler.dispatchMessage(Handler.java:107)
       at android.os.Looper.loop(Looper.java:213)
       at android.app.ActivityThread.main(ActivityThread.java:8178)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:513)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1101)
eliasteeny commented 2 years ago

I can't seem to recreate this issue. After enabling minifyEnabled and shrinkResources my build worked as expected but it's size didn't change at 51.9 mb. I created a new flutter project without any other dependencies. Can you share your app's size before and after enabling these two values ? maybe the reduced app size is caused by other native dependencies.

CarlosVallsCiscar commented 2 years ago

I have been looking for the problem and I think I have found the cause. It has to do with adding another dependency to my App, add_2_calendar. When I add that dependency and build the app in release the app crash.

The minifyEnabled and shrinkResources thing solves the problem, but making the size of my app larger.

I do not know if it is a problem with this pluggin or with add_2_calendar, I will also create an issue in the other.

I created an empty project recreating the issue.

Thanks for answering, the plugin is amazing.