Flutter app to run and profile MNN models on Android (JNI/C++17) with a clean UI, backend probing, and metrics.
• Download: see GitHub Releases — https://github.com/katolikov/MNN_Runner/releases
- Run single or multi-input models with editable shapes.
- Backends: CPU, Vulkan, OpenCL, OpenGL (if the corresponding MNN plugins are bundled).
- High-level profiling metrics only: createInterpreter, createSession, resizeSession, runSession (no per-op timings).
- GPU kernel cache saving for Vulkan/OpenCL.
- Dark mode toggle in-app.
- Inline and fullscreen report viewer with output shapes.
- Place MNN shared objects under
android/app/src/main/jniLibs/<ABI>/
:- Required:
libMNN.so
- Optional plugins (ship only what you use):
libMNN_Vulkan.so
,libMNN_CL.so
,libMNN_GL.so
,libMNN_Express.so
- Required:
- The app loads plugins lazily on demand. We do not auto-load
libMNN_Express.so
to avoid linker warnings when a system copy exists but is not accessible to the app namespace (Android P+ isolated namespaces). - OpenCL: ensure your
libMNN_CL.so
defers loading the vendor driver viadlopen
internally. We do not linklibOpenCL.so
directly.
adb shell
uses a global linker namespace and may find vendor libs; apps run in isolated namespaces and cannot.- Ship all required
.so
files with the APK or link only against NDK-public system libs.
./scripts/push_libs.sh [arm64-v8a|armeabi-v7a]
# On device: export LD_LIBRARY_PATH=/data/local/tmp/mnn/<ABI>
- Install Flutter and run:
flutter pub get
flutter run -d android
(or-d macos
,-d ios
,-d web
)
- Analyze/lint:
flutter analyze
- Format:
dart format .
- Test:
flutter test
- Android 15/16: use
scripts/screenshot_android.sh
to build, install, launch, and capture a screenshot todocs/screenshot_android.png
.- Usage:
scripts/screenshot_android.sh [serial]
- Pass a device serial if multiple devices are connected: find with
adb devices
. - Ensure an emulator or device on Android 15/16 is connected and unlocked.
- Usage:
- Ensure
android/app/src/main/jniLibs/<ABI>/libMNN*.so
exist for the ABIs you target. - Build:
flutter build apk --release
- Output:
build/app/outputs/flutter-apk/app-release.apk
- Output:
Note on minSdk: modern Flutter (3.24+) recommends minSdkVersion >= 21
. Vulkan also requires API 24+ on most devices. Building for API 16 is not supported by current Flutter + plugins. If you absolutely need API 16, you’ll have to fork the project and rework the toolchain and feature set (e.g., disable modern backends and update Gradle/Flutter), which is out of scope here.
Repository: https://github.com/katolikov/MNN_Runner
- Ensure native libs are committed under
android/app/src/main/jniLibs/
. - Tag a version (e.g.,
git tag v1.0.0 && git push origin v1.0.0
). - The provided GitHub Action builds a release APK and attaches it to the tag’s Release page.
We include a simple workflow under .github/workflows/android-release.yml
. It builds a release APK on tagged pushes and uploads it as a release asset. You can adjust Flutter version as needed.
- Add a main app screenshot to
docs/screenshot.png
for the README preview. - Optionally add more under
docs/screenshots/
and reference them here:

- JNI expects the MNN headers under
android/app/src/main/cpp/third_party/MNN/include
andlibMNN.so
per-ABI underandroid/app/src/main/jniLibs/<ABI>/
. - Dart MethodChannel name is
mnn_runner
; methodrunModel
expects a JSON with keysmodelPath
,inputShape
(orinputShapes
),backend
,memoryMode
,precisionMode
,powerMode
,threads
,inputFill
, and flagsprofile
,cache
.