You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/source/using-executorch-android.md
+71-3Lines changed: 71 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -68,17 +68,85 @@ dependencies {
68
68
69
69
Now you can compile your app with the ExecuTorch Android library.
70
70
71
-
###Building from Source
71
+
## Building from Source
72
72
73
-
TODO Instructions on re-creating and customizing the Android AAR.
73
+
`build/build_android_library.sh` is a helper script to build the Java library (into .jar), native library (into .so), and the packaged AAR file. It can also build
74
+
demo apps to showcase the AAR is integrated into a user app correctly.
75
+
76
+
You need Android [SDK](https://developer.android.com/studio) and [NDK](https://developer.android.com/ndk/downloads) to use it.
77
+
78
+
Current NDK version used in ExecuTorch CI: r27b.
79
+
80
+
You need to set `ANDROID_NDK` to the correct NDK root (containing NOTICE file).
81
+
82
+
```
83
+
export ANDROID_NDK=/path/to/ndk
84
+
sh build/build_android_library.sh
85
+
```
86
+
87
+
### Optional environment variables
88
+
89
+
Optionally, set these environment variables before running `build_android_library.sh`.
90
+
91
+
#### ANDROID_ABIS
92
+
Set environment variable `ANDROID_ABIS` to either `arm64-v8a` or `x86_64` if you only need to build the native library for one ABI only.
93
+
```
94
+
export ANDROID_ABIS=arm64-v8a
95
+
# or
96
+
# export ANDROID_ABIS=x86_64
97
+
sh build/build_android_library.sh
98
+
```
99
+
100
+
#### EXECUTORCH_CMAKE_BUILD_TYPE
101
+
Set environment variable `EXECUTORCH_CMAKE_BUILD_TYPE` to `Release` or `Debug` based on your needs.
102
+
103
+
#### Using MediaTek backend
104
+
105
+
To use [MediaTek backend](https://pytorch.org/executorch/main/backends-mediatek.html),
106
+
after installing and setting up the SDK, set `NEURON_BUFFER_ALLOCATOR_LIB` and `NEURON_USDK_ADAPTER_LIB` to the corresponding path.
107
+
108
+
#### Using Qualcomm AI Engine Backend
109
+
110
+
To use [Qualcomm AI Engine Backend](https://pytorch.org/executorch/main/backends-qualcomm.html#qualcomm-ai-engine-backend),
111
+
after installing and setting up the SDK, set `QNN_SDK_ROOT` to the corresponding path
74
112
75
113
## Android Backends
76
114
77
115
TODO Describe commonly used backends, including XNN, Vulkan, and NPUs.
78
116
79
117
## Runtime Integration
80
118
81
-
TODO Code sample in Java
119
+
Here is an example code sample in Java that demonstrates how to integrate ExecuTorch into an Android app:
0 commit comments