-
Notifications
You must be signed in to change notification settings - Fork 67
Static fields or methods does not exist in release build #1626
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
Comments
Thanks for making the code available, I will try to reproduce it tomorrow. |
Thanks a lot! If it helps I can create a minimal reproducible example project, too. Just let me know. (: |
I would appreciate a more minimal example of course if you can! |
I was finally able to reproduce the bug. It turns out, it was a misconfigured proguard-rules file all along. 🥲 The only place the proguard-rules.pro file gets used is for a flutter plugin The error message in this case was misleading. The function itself existed but the returned type is renamed or doesn't exist? I'm not really sure. For example the method signature in the screenshot of my initial post: Side note: After adding the proguard-rules.pro file in the correct location Unfortunally, I couldn't find a way to inject proguard rules from the flutter plugin, only from the flutter app. See flutter/flutter#136909. Thanks a lot for your help @HosseinYousefi. Closing this issue now. (: |
I'm glad you were able to solve it.
You can use consumer proguard rules in this case, I use them for |
That's exactly what I was looking for! Thanks a lot! |
Description
I'd like to use jnigen for a flutter plugin in combination with a platform view. To pass the kotlin instance to dart I created a kotlin object class
MapLibreMapRegistry
. After I run jnigen I can access the singelton instance viaMapLibreMapRegistry.INSTANCE
. This works find when I run the app in debug mode.However, when I build and run the app in release mode with
flutter build apk
jni can't find the staticINSTANCE
field.I added some (currently a lot) proguard keep rules and added
@Keep
annotations to make sure that proguard is no problem.rules in proguard-rules.pro (click to expand)
When I analyze the APK, all fields and methods exist.

MapLibreMapRegistry byte code (click to expand)
I added another java class
MapLibreMapRegistryJava
to see if the problem is related to kotlin but the static methods can't be found either.MapLibreMapRegistryJava content (click to expand)
I'm currently a bit lost how to debug this problem further, so I'd be glad for any help or hint.
The project is published on GitHub:
The text was updated successfully, but these errors were encountered: