What you’ll build
An Android app that:- Loads the Edge Impulse C++ library through the Android NDK
- Runs inference on static test features
- Displays the classification results
Prerequisites
- A trained Edge Impulse model
- Android Studio with the NDK and CMake installed
1. Clone the repository
2. Download TensorFlow Lite libraries
3. Export your model
- In Edge Impulse Studio, go to Deployment.
- Select Android (C++ library).
- Click Build and download the
.zipfile.
4. Integrate the model
Extract the downloaded.zip file and copy its contents, except CMakeLists.txt, into example_static_buffer/app/src/main/cpp/. The folder then looks like this:
5. Add test features
- In the studio, go to Model testing.
- Click a test sample.
- Copy the Raw features.
- Paste them into
native-lib.cpp:
6. Build and run
- Open the project in Android Studio.
- Select Build -> Make Project.
- Run the app on a device or emulator.
How it works
Native inference
Java/Kotlin bridge
Troubleshooting
Build fails with 'undefined reference to run_classifier'
Build fails with 'undefined reference to run_classifier'
The model files aren’t in the right place. Check that
edge-impulse-sdk/, model-parameters/, and tflite-model/ are all in app/src/main/cpp/, and that you kept the existing CMakeLists.txt.App crashes on launch
App crashes on launch
The native library didn’t load. Check that
System.loadLibrary("test_cpp") matches your library name, and look for compilation errors in the Build output.Wrong classification results
Wrong classification results
The test features don’t match the model input. Copy the features from the Model testing page, and check that the feature count matches the model’s input size and that the axis order matches your training data.