In this Learning Path, you will learn how to build and deploy a simple LLM-based chat app to an Android device using ExecuTorch and XNNPACK. You will learn how to build the ExecuTorch runtime for Llama models, build JNI libraries for the Android application, and use the libraries in the application.
The first step is to prepare a development environment with the required software:
The instructions assume macOS with Apple Silicon, an x86 Debian, or Ubuntu Linux machine with at least 16GB of RAM.
Follow these steps to install and configure Android Studio:
Download and install the latest version of Android Studio .
Start Android Studio and open the Settings
dialog.
Navigate to Languages & Frameworks -> Android SDK
.
In the SDK Platforms
tab, check Android 14.0 ("UpsideDownCake")
.
Next, install the specific version of the Android NDK that you need by first installing the Android command line tools:
Linux:
curl https://dl.google.com/android/repository/commandlinetools-linux-11076708_latest.zip -o commandlinetools.zip
macOS:
curl https://dl.google.com/android/repository/commandlinetools-mac-11076708_latest.zip -o commandlinetools.zip
Unzip the Android command line tools:
unzip commandlinetools.zip
Install the NDK in the directory that Android Studio installed the SDK. This is generally ~/Library/Android/sdk
by default:
export ANDROID_HOME="$(realpath ~/Library/Android/sdk)"
./cmdline-tools/bin/sdkmanager --sdk_root="${ANDROID_HOME}" --install "ndk;25.0.8775105"
Open the Java SE 17 Archive Downloads page in your browser.
Select an appropriate download for your development machine operating system.
Downloads are available for macOS as well as Linux.
For macOS use Homebrew :
brew install git
For Linux, use the package manager for your distribution:
sudo apt install git-all
For macOS:
brew install python@3.10
For Linux:
sudo apt update
udo apt install software-properties-common -y
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt install Python3.10
You now have the required development tools installed.