SIGN IN SIGN UP

Android automate cmake build in gradle (#2838)

Summary:
Automatically invoke `examples/demo-apps/android/LlamaDemo/setup.sh` in `gradle setup` task. Users doesn't need to run examples/demo-apps/android/LlamaDemo/setup.sh manually.

Test (follow https://github.com/pytorch/executorch/blob/ba824577f495f7522cc9be91d38cf8ad187bc841/examples/demo-apps/android/LlamaDemo/README.md):
1. Fetch source
```
git fetch origin pull/2838/head
git checkout FETCH_HEAD
```
2. Push model
```
adb shell mkdir -p /data/local/tmp/llama
adb push llama2.pte /data/local/tmp/llama <--- Use your pte file
adb push tokenizer.bin /data/local/tmp/llama <--- Use your tokenizer.bin
```
3. Build JNI
```
export ANDROID_NDK=<path_to_android_ndk> <---- You can download NDK from https://developer.android.com/ndk/downloads
export ANDROID_ABI=arm64-v8a

pushd examples/demo-apps/android/LlamaDemo
./gradlew :app:setup
popd
```
4. Build app
* (Method 1) Open Android Studio and select "Open an existing Android Studio project" to open examples/demo-apps/android/LlamaDemo. Run the app (^R). This builds and launches the app on the phone.
* (Method 2)
```
export ANDROID_HOME=--sanitized--

Pull Request resolved: https://github.com/pytorch/executorch/pull/2838

Reviewed By: cccclai

Differential Revision: D55717885

Pulled By: kirklandsign

fbshipit-source-id: fc2c47219860c8245a1b7728abee46467c846908
H
Hansong Zhang committed
b5d400247cd32dc32572dfe96187cd73f23f6a98
Parent: ea3927a
Committed by Facebook GitHub Bot <facebook-github-bot@users.noreply.github.com> on 4/4/2024, 1:08:18 AM