From db099e924f99624935f96c76fb864bb87be2f5a5 Mon Sep 17 00:00:00 2001 From: Hansong <107070759+kirklandsign@users.noreply.github.com> Date: Wed, 19 Mar 2025 21:31:47 -0700 Subject: [PATCH 1/3] [Android docs] Add maven part Now user can also add executorch android lib as a maven dependency. --- docs/source/using-executorch-android.md | 29 +++++++++++++++++++------ 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/docs/source/using-executorch-android.md b/docs/source/using-executorch-android.md index 326b29de27c..8af11b1f5b4 100644 --- a/docs/source/using-executorch-android.md +++ b/docs/source/using-executorch-android.md @@ -6,7 +6,7 @@ Note: This page covers Android app integration through the AAR library. The Exec ## Installation -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. +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. ### Contents of library @@ -22,7 +22,21 @@ The AAR artifact contains the Java library for users to integrate with their Jav - LLaMa-specific Custom ops library. - Comes with two ABI variants, arm64-v8a and x86\_64. -## Downloading AAR +## Using AAR from Maven Central + +Simply add the following `org.pytorch:executorch-android` to your Android app dependency (build.gradle), and build your app. + +For example: +``` +# app/build.gradle.kts +dependencies { + implementation("org.pytorch:executorch-android:0.5.1") +} +``` + +## 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. ### Released versions (recommended) @@ -36,13 +50,13 @@ The AAR artifact contains the Java library for users to integrate with their Jav | ------- | --- | ------- | | 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) | -## Using prebuilt libraries +## Using AAR file -To add the Java library to your app: +To add the AAR file to your app: 1. Download the AAR. 2. Add it to your gradle build rule as a file path. -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: +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.5.1") @@ -58,7 +72,7 @@ curl https://ossci-android.s3.amazonaws.com/executorch/release/v0.5.0-rc3/execut And include it in gradle: ``` -# app/build.grardle.kts +# app/build.gradle.kts dependencies { implementation(files("libs/executorch.aar")) implementation("com.facebook.soloader:soloader:0.10.5") @@ -77,9 +91,10 @@ You need Android [SDK](https://developer.android.com/studio) and [NDK](https://d Current NDK version used in ExecuTorch CI: r27b. -You need to set `ANDROID_NDK` to the correct NDK root (containing NOTICE file). +You need to set `ANDROID_HOME` to Android SDK home and `ANDROID_NDK` to the correct NDK root (containing NOTICE file). ``` +export ANDROID_HOME=/path/to/sdk export ANDROID_NDK=/path/to/ndk sh build/build_android_library.sh ``` From 2f3817a5783d4a868f6dd0415d0f78a105333d44 Mon Sep 17 00:00:00 2001 From: Hansong <107070759+kirklandsign@users.noreply.github.com> Date: Wed, 19 Mar 2025 21:35:03 -0700 Subject: [PATCH 2/3] Update using-executorch-android.md --- docs/source/using-executorch-android.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/source/using-executorch-android.md b/docs/source/using-executorch-android.md index 8af11b1f5b4..3908f809154 100644 --- a/docs/source/using-executorch-android.md +++ b/docs/source/using-executorch-android.md @@ -24,7 +24,9 @@ The AAR artifact contains the Java library for users to integrate with their Jav ## Using AAR from Maven Central -Simply add the following `org.pytorch:executorch-android` to your Android app dependency (build.gradle), and build your app. +TODO: Add the link to maven page. + +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. For example: ``` @@ -34,6 +36,8 @@ dependencies { } ``` +Note: `org.pytorch:executorch-android:0.5.1` corresponds to executorch v0.5.0. + ## 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. From dca893db510df3334b9a10330910f636c06190fd Mon Sep 17 00:00:00 2001 From: Hansong <107070759+kirklandsign@users.noreply.github.com> Date: Thu, 20 Mar 2025 10:10:28 -0700 Subject: [PATCH 3/3] Update using-executorch-android.md --- docs/source/using-executorch-android.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/using-executorch-android.md b/docs/source/using-executorch-android.md index 3908f809154..e499ab183e6 100644 --- a/docs/source/using-executorch-android.md +++ b/docs/source/using-executorch-android.md @@ -24,7 +24,7 @@ The AAR artifact contains the Java library for users to integrate with their Jav ## Using AAR from Maven Central -TODO: Add the link to maven page. +ExecuTorch is available on [Maven Central](https://mvnrepository.com/artifact/org.pytorch/executorch-android). 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.