Build an Android chat application with ONNX Runtime API
Introduction
Create a development environment
Build ONNX Runtime
Build ONNX Runtime Generate() API
Run a benchmark on an Android phone
Build and run an Android chat app
Next Steps
Build an Android chat application with ONNX Runtime API
Review frequently asked questions
These FAQs were drafted with an approved AI-assisted workflow and reviewed by Arm contributors before publication. Human technical review remains part of the process so the final page reflects engineering rigor, accuracy, and Arm editorial standards.
Use the
CMAKE_TOOLCHAIN_FILE option with the android.toolchain.cmake path from the installed NDK. Ensure the path and version match the NDK you installed.Copy
src\ort_genai.h and src\ort_genai_c.h into examples\c\include. If these headers are missing, the model runner configuration will fail with include errors.The build is successful when the configure and build stages complete without errors and produce Android-targeted binaries and headers. You should then be able to configure and build the
examples\c model runner without missing include or link errors.The run executes on the Android device and prints performance metrics. Proceed when the metrics appear and the process exits cleanly without runtime errors.
Check out commit
7a635daae48450ff142e5c0848a564b245f04112. You might be able to use a later commit, but the Learning Path was tested with that specific commit.