Skip to content
This repository has been archived by the owner on Aug 28, 2024. It is now read-only.

Flutter App crashed in release version only #266

Open
baleksey opened this issue Sep 26, 2022 · 4 comments · May be fixed by #269
Open

Flutter App crashed in release version only #266

baleksey opened this issue Sep 26, 2022 · 4 comments · May be fixed by #269

Comments

@baleksey
Copy link

Debug version works fine. But the same release version crashed on module = LiteModuleLoader.load(absPath); in MainActivity.java with errors:

E/AndroidRuntime(15751): FATAL EXCEPTION: main
E/AndroidRuntime(15751): Process: com.example.pyml, PID: 15751
E/AndroidRuntime(15751): java.lang.ExceptionInInitializerError
E/AndroidRuntime(15751):        at org.pytorch.c.a(Unknown Source:2)
E/AndroidRuntime(15751):        at com.example.pyml.MainActivity.P(Unknown Source:234)
E/AndroidRuntime(15751):        at com.example.pyml.MainActivity.O(Unknown Source:0)
E/AndroidRuntime(15751):        at i.a.a(Unknown Source:2)
E/AndroidRuntime(15751):        at x.j$a.a(Unknown Source:17)
E/AndroidRuntime(15751):        at l.c.k(Unknown Source:18)
E/AndroidRuntime(15751):        at l.c.l(Unknown Source:20)
E/AndroidRuntime(15751):        at l.c.h(Unknown Source:0)
E/AndroidRuntime(15751):        at l.b.run(Unknown Source:12)
E/AndroidRuntime(15751):        at android.os.Handler.handleCallback(Handler.java:938)
E/AndroidRuntime(15751):        at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(15751):        at android.os.Looper.loopOnce(Looper.java:226)
E/AndroidRuntime(15751):        at android.os.Looper.loop(Looper.java:313)
E/AndroidRuntime(15751):        at android.app.ActivityThread.main(ActivityThread.java:8669)
E/AndroidRuntime(15751):        at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(15751):        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571)
E/AndroidRuntime(15751):        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1135)
E/AndroidRuntime(15751): Caused by: java.lang.ClassNotFoundException: org.pytorch.PyTorchAndroid
E/AndroidRuntime(15751):        at java.lang.Runtime.nativeLoad(Native Method)
E/AndroidRuntime(15751):        at java.lang.Runtime.nativeLoad(Runtime.java:1121)
E/AndroidRuntime(15751):        at java.lang.Runtime.loadLibrary0(Runtime.java:1075)
E/AndroidRuntime(15751):        at java.lang.Runtime.loadLibrary0(Runtime.java:998)
E/AndroidRuntime(15751):        at java.lang.System.loadLibrary(System.java:1661)
E/AndroidRuntime(15751):        at j.c.a(Unknown Source:0)
E/AndroidRuntime(15751):        at j.a.c(Unknown Source:8)
E/AndroidRuntime(15751):        at org.pytorch.LiteNativePeer.<clinit>(Unknown Source:16)
E/AndroidRuntime(15751):        ... 17 more

Tried many org.pytorch:pytorch_android_lite versions - result always the same. Attaching the full and minimal Flutter project to reproduce the issue (24 Mb, model included). First try on debug - you'll receive "ML: SUCCESS" message on button press. Then on Release - app will instantly closes on loading the model.

mlfx_gt.zip

@COO1M
Copy link

COO1M commented Oct 5, 2022

the same, did you solve it? I found that changing minifyEnabled to false works, but it's not a good solution

@baleksey
Copy link
Author

baleksey commented Oct 5, 2022

@COO1M Unfortunately nope. Instead started to learn native Android/Java development in order to make desired ML based app. Surprisingly, even after Flutter simplicity I just love to work now in Android Studio and code in java. Almost all examples here works great after that.

@COO1M
Copy link

COO1M commented Oct 5, 2022

Not Flutter, my problem happens in native Android, and now it has been solved. As I guessed, something was obfuscated by ProGuard. Since I didn't find the official proguard rules of Pytorch_Android, I added -keep class org.pytorch.** {*;} -keep class com.facebook.** {*;}, it worked.

@baleksey
Copy link
Author

baleksey commented Oct 5, 2022

Git it, thank you for solution!

@COO1M COO1M linked a pull request Oct 5, 2022 that will close this issue
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants