# Agent brief: Android Studio project and LiteRT

- **Lesson id:** 04
- **Goal:** Package the model in an Android Kotlin app and allocate a LiteRT CompiledModel.
- **Prerequisites:** `clothing.tflite`, Android Studio/JDK/SDK, emulator or device, [human lesson](04-android-studio-litert.html).
- **Inputs:** Android app with min SDK 23 and model file.
- **Outputs/artifacts:** Gradle dependency, `assets/clothing.tflite`, one compiled model and buffer allocation.

## Steps

1. Create an Empty Activity Kotlin app with compile/target SDK 35 and min SDK 23.
2. Add `com.google.ai.edge.litert:litert:2.1.5` or a newer verified published stable version.
3. Put the model under `app/src/main/assets/` and check it with APK Analyzer.
4. Copy the asset to `filesDir`, call `CompiledModel.create(path, CompiledModel.Options(Accelerator.CPU))`, then create input/output buffers once.
5. Build and install the debug APK and check that the asset file is not empty.

## Constraints

Use the current LiteRT name and API. Do not default to `org.tensorflow:tensorflow-lite` or manual older delegates. Link the [human lesson](04-android-studio-litert.html).

## Key concepts

- Kotlin app, min SDK 23. LiteRT dependency is `com.google.ai.edge.litert:litert`.
- Copy `clothing.tflite` from assets to `filesDir`, then pass the absolute path.
- Create `CompiledModel` with `CompiledModel.Options(Accelerator.CPU)`.
- Allocate input and output buffers once. Start on CPU.

## Takeaways

- Confirm `assets/clothing.tflite` in APK Analyzer before you add UI.
- Do not recreate `CompiledModel` or buffers on every image.
- Do not use the older `Interpreter` API for new code.

## Acceptance checks

Gradle sync and build succeed, the asset is packaged, and model setup is outside the per-image callback.
