Skip to content

Commit 3bb9b0b

Browse files
kirklandsignDannyYuyang-quic
authored andcommitted
[Android docs] Add maven part
Differential Revision: D71526394 Pull Request resolved: pytorch#9442
1 parent 24a5152 commit 3bb9b0b

File tree

1 file changed

+26
-7
lines changed

1 file changed

+26
-7
lines changed

docs/source/using-executorch-android.md

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Note: This page covers Android app integration through the AAR library. The Exec
66

77
## Installation
88

9-
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 S3. Users can also build the AAR from source.
9+
All ExecuTorch Android libraries are packaged into an [Android library (AAR)](https://developer.android.com/studio/projects/android-library), `executorch.aar` for both generic (image/audio processing) and LLM (LLaMA) use case. In each release, prebuilt AAR artifacts are uploaded to [Maven](https://repo.maven.apache.org/maven2/org/pytorch/executorch-android/) and S3. Users can also build the AAR from source.
1010

1111
### Contents of library
1212

@@ -22,7 +22,25 @@ The AAR artifact contains the Java library for users to integrate with their Jav
2222
- LLaMa-specific Custom ops library.
2323
- Comes with two ABI variants, arm64-v8a and x86\_64.
2424

25-
## Downloading AAR
25+
## Using AAR from Maven Central
26+
27+
ExecuTorch is available on [Maven Central](https://mvnrepository.com/artifact/org.pytorch/executorch-android).
28+
29+
Simply add the target [`org.pytorch:executorch-android:0.5.1`](https://repo.maven.apache.org/maven2/org/pytorch/executorch-android/0.5.1/) to your Android app dependency (build.gradle), and build your app.
30+
31+
For example:
32+
```
33+
# app/build.gradle.kts
34+
dependencies {
35+
implementation("org.pytorch:executorch-android:0.5.1")
36+
}
37+
```
38+
39+
Note: `org.pytorch:executorch-android:0.5.1` corresponds to executorch v0.5.0.
40+
41+
## Using AAR file directly
42+
43+
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.
2644

2745
### Released versions (recommended)
2846

@@ -36,13 +54,13 @@ The AAR artifact contains the Java library for users to integrate with their Jav
3654
| ------- | --- | ------- |
3755
| 2025-02-27 | [executorch.aar](https://ossci-android.s3.amazonaws.com/executorch/release/executorch-20250227/executorch.aar) | [executorch.aar.sha256sums](https://ossci-android.s3.amazonaws.com/executorch/release/executorch-20250227/executorch.aar.sha256sums) |
3856

39-
## Using prebuilt libraries
57+
## Using AAR file
4058

41-
To add the Java library to your app:
59+
To add the AAR file to your app:
4260
1. Download the AAR.
4361
2. Add it to your gradle build rule as a file path.
4462

45-
An AAR file itself does not contain dependency info. 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:
63+
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:
4664
```
4765
implementation("com.facebook.soloader:soloader:0.10.5")
4866
implementation("com.facebook.fbjni:fbjni:0.5.1")
@@ -58,7 +76,7 @@ curl https://ossci-android.s3.amazonaws.com/executorch/release/v0.5.0-rc3/execut
5876

5977
And include it in gradle:
6078
```
61-
# app/build.grardle.kts
79+
# app/build.gradle.kts
6280
dependencies {
6381
implementation(files("libs/executorch.aar"))
6482
implementation("com.facebook.soloader:soloader:0.10.5")
@@ -77,9 +95,10 @@ You need Android [SDK](https://developer.android.com/studio) and [NDK](https://d
7795

7896
Current NDK version used in ExecuTorch CI: r27b.
7997

80-
You need to set `ANDROID_NDK` to the correct NDK root (containing NOTICE file).
98+
You need to set `ANDROID_HOME` to Android SDK home and `ANDROID_NDK` to the correct NDK root (containing NOTICE file).
8199

82100
```
101+
export ANDROID_HOME=/path/to/sdk
83102
export ANDROID_NDK=/path/to/ndk
84103
sh build/build_android_library.sh
85104
```

0 commit comments

Comments
 (0)