Crash on onProgressValues when shrinking code
danydev opened this issue · 1 comments
danydev commented
I'm experiencing this crash
java.lang.NoClassDefFoundError: com.googlecode.tesseract.android.TessBaseAPI
at com.xxx.yyy.MainActivity.a(Unknown Source:291)
at com.xxx.yyy.a.onMethodCall(Unknown Source:2)
at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(Unknown Source:17)
at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(Unknown Source:57)
at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(Unknown Source:4)
at android.os.MessageQueue.nativePollOnce(Native Method)
at android.os.MessageQueue.next(MessageQueue.java:326)
at android.os.Looper.loop(Looper.java:160)
at android.app.ActivityThread.main(ActivityThread.java:6863)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:537)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Caused by: java.lang.NoSuchMethodError: no non-static method "Lcom/googlecode/tesseract/android/TessBaseAPI;.onProgressValues(IIIIIIIII)V"
at com.googlecode.tesseract.android.TessBaseAPI.nativeClassInit(Native Method)
at com.googlecode.tesseract.android.TessBaseAPI.<clinit>(Unknown Source:20)
when building the apk with flutter. See related flutter issue here. Flutter shrinks the code, and given onProgressValues
looks unused (because called from native code) it is removed.
We should either update the proguard file to keep it or use the @Keep notation.
To be clear this issue is not limited to flutter, you would have the same problem even when compiling a normal android project using Tesseract4Android when shrinking the code, but it's now more evident for flutter users because flutter shrinks by default starting from the latest version.
Reference https://developer.android.com/studio/build/shrink-code