This example shows how to write custom java code in android/app/src and call
it using bindings generated by JNIgen.
- Run
flutter runto run the app.
These are general steps to integrate Java code into a Flutter project using JNIgen.
- Place Java code in a suitable package folder under the
android/subproject of the flutter app. - Create a JNIgen configuration script like
tool/jnigen.dartin this example. - Run
flutter pub get. - Generate bindings by running that script with
dart run. - To prevent tree shaking of your custom classes (which are always accessed
reflectively in JNI) use either the
@Keepannotation (androidx.annotation.Keep) for code written in the application itself, or a proguard-rules file for external libraries. - Build and run the app.