This tutorial shows how to run an Edge Impulse model on Android using hardcoded test data with no sensors required. It’s a useful starting point before moving on to camera, audio, or motion input.Documentation Index
Fetch the complete documentation index at: https://docs.edgeimpulse.com/llms.txt
Use this file to discover all available pages before exploring further.
What you’ll build
A basic Android app that:- Loads a C++ model via Android NDK
- Runs inference on static test features
- Displays classification results
Prerequisites
- Trained Edge Impulse model
- Android Studio with NDK and CMake installed
- Basic familiarity with Android development
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
.zip
4. Integrate the model
- Extract the downloaded
.zipfile - Copy all files to:
5. Add test features
- In Studio, go to Model testing
- Click on a test sample
- Copy the raw features
- Paste into
native-lib.cpp:
6. Build and run
- Open the project in Android Studio
- Build → Make Project
- Run 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'
Cause: Model files not copied correctlySolution:
- Ensure all folders (edge-impulse-sdk, model-parameters, tflite-model) are in
app/src/main/cpp/ - Don’t replace the existing
CMakeLists.txt
App crashes on launch
App crashes on launch
Cause: Native library not loadedSolution:
- Verify
System.loadLibrary("test_cpp")matches your library name - Check Build output for compilation errors
Wrong classification results
Wrong classification results
Cause: Test features don’t match model inputSolution:
- Copy features from Studio’s Model Testing page
- Ensure feature count matches model input size
- Check feature order (x, y, z for accelerometer, etc.)