Using ExecuTorch on Android#
🚀 Quick Start: New to ExecuTorch ? Jump to Using AAR from Maven Central for the fastest setup, then see the Runtime Integration example.
To use from Android, ExecuTorch provides Java/Kotlin API bindings and Android platform integration, available as an AAR file. Note: This page covers Android app integration through the AAR library. The ExecuTorch C++ APIs can also be used from Android native, and the documentation can be found on this page about cross compilation.
Installation#
Choose your installation method:
Maven Central (recommended): Easiest for most developers
Direct AAR file: For specific versions or offline development
Build from source: For custom backends or contributions
All ExecuTorch Android libraries are packaged into an Android library (AAR), executorch.aar for both generic (image/audio processing) and LLM (LLaMA) use case. In each release, prebuilt AAR artifacts are uploaded to Maven and S3. Users can also build the AAR from source.
Contents of library#
The AAR artifact contains the Java library for users to integrate with their Java/Kotlin application code, as well as the corresponding JNI library (.so file), which is loaded by the Java code during initialization.
JNI contains the JNI binding for the corresponding Java code, and ExecuTorch native library, including
Core ExecuTorch runtime libraries
XNNPACK backend
Portable kernels
Optimized kernels
Quantized kernels
LLaMa-specific Custom ops library.
Comes with two ABI variants, arm64-v8a and x86_64.
The AAR library can be used for generic Android device with arm64-v8a or x86_64 architecture. It can be used across form factors, including phones, tablets, tv boxes, etc, as it does not contain any UI components.
Using AAR from Maven Central#
✅ Recommended for most developers ExecuTorch is available on Maven Central. Simply add the target org.pytorch:executorch-android:${executorch_version} to your Android app dependency (build.gradle), and build your app. For example:
app/build.gradle.kts
dependencies {
implementation("org.pytorch:executorch-android:${executorch_version}")
}
Note: If you want to use release v1.0.0, please use dependency org.pytorch:executorch-android:1.0.0.
Click the screenshot below to watch the demo video on how to add the package and run a simple ExecuTorch model with Android Studio.
Using AAR file directly#
You can also directly specify an AAR file in the app. We upload pre-built AAR to S3 during each release, or as a snapshot.
Latest Released versions (Recommended)#
Starting from v1.0.0, there are respective executorch.aar library available by backends
Older Released versions#
Download the older released version
Snapshots from main branch#
Starting from 2025-04-12, you can download nightly main branch snapshots:
executorch.aar:https://ossci-android.s3.amazonaws.com/executorch/release/snapshot-{YYYYMMDD}/executorch.aarexecutorch.aar.sha256sums:https://ossci-android.s3.amazonaws.com/executorch/release/snapshot-{YYYYMMDD}/executorch.aar.sha256sumsReplace
YYYYMMDDwith the actual date you want to use.AAR file is generated by this workflow.
For example:
curl -O https://ossci-android.s3.amazonaws.com/executorch/release/snapshot-20250412/executorch.aar
curl -O https://ossci-android.s3.amazonaws.com/executorch/release/snapshot-20250412/executorch.aar.sha256sums
We aim to make every daily snapshot available and usable. However, for best stability, please use releases, not snapshots.
Using AAR file#
To add the AAR file to your app: Download the AAR. Add it to your gradle build rule as a file path. An AAR file itself does not contain dependency info, unlike the Maven one which bundled with pom.xml. The Java package requires fbjni and soloader, and currently requires users to explicitly declare the dependency. Therefore, two more dependencies in gradle rule is required:
implementation("com.facebook.soloader:soloader:0.10.5")
implementation("com.facebook.fbjni:fbjni:0.7.0")
Example usage#
In your app working directory, such as executorch-examples/llm/android/LlamaDemo,
mkdir -p app/libs
curl https://ossci-android.s3.amazonaws.com/executorch/release/${executorch_version}/executorch.aar -o app/libs/executorch.aar
And include it in gradle:
app/build.gradle.kts
dependencies {
implementation