litert-lm
하는 일
이 스킬은 CPU나 GPU를 이용해 휴대폰에서 직접 텍스트 언어 모델을 실행하는 Android 앱을 만드는 방법을 안내합니다. 기기 안에서 바로 작동하는 채팅, 요약 또는 추출 기능을 추가하려는 Android 개발자를 위한 스킬입니다.
사용하는 경우
- ✓휴대폰에서 직접 실행되는 채팅이나 요약 기능을 Android 앱에 넣고 싶을 때.
- ✓Hugging Face의 Gemma, Qwen, Llama 또는 Phi 같은 .litertlm 모델을 사용할 계획일 때.
- ✓기기 내 언어 모델을 위해 Gradle 설정과 GPU 설정이 필요할 때.
스킬 링크
https://github.com/android/skills/blob/main/device-ai/litert/litert-lm/SKILL.md복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.
사용 방법
가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.
바로 붙여넣을 수 있는 메시지
Claude Code, Codex, Cursor용입니다. 프로젝트 폴더에서 실행하면 스킬이 설치됩니다.
SKILL.md를 다운로드해 에이전트의 스킬 폴더에 넣으세요.
AI에게 요청하는 예시
“Gemma 모델을 사용해 내 Android 앱에 기기 내 채팅 기능을 추가해 주세요.”
매주 새 스킬 5개. 읽는 데 1분.
작동 방식
이 스킬은 LiteRT-LM 라이브러리를 추가하고, 매니페스트에 GPU 항목을 설정하고, 기기 저장소의 모델 파일을 불러오는 과정을 안내합니다. 이후 앱에서 모델을 실행하는 방법을 보여 줍니다.
기술 내용 (원본 SKILL.md)
작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.
This skill provides step-by-step guidance for building an Android app that runs
an open text LLM through the LiteRT-LM Kotlin API
(com.google.ai.edge.litertlm) on the CPU or the GPU. The model is one
.litertlm file. Images, audio, tool calling, and NPU backends aren't covered.
For vision and audio models with .tflite files, suggest the litert-runtime
skill.
When a LiteRT-LM class or method that this skill uses doesn't compile, you must read the LiteRT-LM Android guide and the LiteRT-LM README before changing the code.
Prerequisites
- A Kotlin Android project (the Android Studio Empty Activity template is enough). The
litertlm-android0.18.0 AAR declaresminSdk24. - The dependency in the app-level
build.gradle.ktsfile from Google Maven:implementation("com.google.ai.edge.litertlm:litertlm-android:0.18.0"). Google Maven lists the later releases. - For the GPU backend, two
uses-native-libraryentries inside<application>inAndroidManifest.xml. Add theINTERNETpermission if the app downloads the model. - The model file lives on the device's file system (hundreds of MB to a few GB), never in
assets/or in the APK.
Critical mandates
- Dependency first : Before writing code that imports
com.google.ai.edge.litertlm, add thelitertlm-androiddependency from Step 1 if the project lacks it. Verify with./gradlew assembleDebug. - Background initialization :
Engine(config).initialize()loads the weights and blocks for seconds. Call it on a background thread, never on the main thread. - Single owner : One single-thread executor owns the
Engineand theConversation. Creation, streaming, cancellation, and closing run on it. - Close once :
EngineandConversationareAutoCloseable. A secondcloseon either throwsIllegalStateException. So doescloseon an engine whoseinitializethrew. Store the engine only afterinitializereturns. - Model outside the APK : Pass an absolute path to
EngineConfig. Never bundle a.litertlmfile inassets/.
Detailed steps
Step 1: Configure Gradle and the manifest
Search the project for libs.versions.toml, app/build.gradle.kts, and
AndroidManifest.xml before editing build files. Configure minSdk and add the
LiteRT-LM dependency in app/build.gradle.kts:
android {
defaultConfig {
minSdk = 24
}
}
dependencies {
implementation("com.google.ai.edge.litertlm:litertlm-android:0.18.0")
}
If the project uses Hilt, check the Dagger version first. litertlm-android
0.18.0 carries Kotlin 2.4 metadata, which Hilt 2.59.2 can't read. The build
then fails in hiltJavaCompileDebug with Provided Metadata instance has version 2.4.0, while maximum supported version is 2.3.0. Pick one fix:
- Path A : Upgrade the Hilt version (
com.google.dagger) to 2.60.1 or later. Ask the user before editinggradle/libs.versions.toml. - Path B : Keep the Hilt version and add a later version of the metadata reader to the annotation processor path in
app/build.gradle.kts:
dependencies {
ksp("org.jetbrains.kotlin:kotlin-metadata-jvm:2.4.21")
}
For the GPU backend, add both lines inside <application> in
AndroidManifest.xml. Add the INTERNET permission outside <application>
when the app downloads the model:
<uses-permission android:name="android.permission.INTERNET"/>
<application>
<uses-native-library
android:name="libvndksupport.so"
android:required="false"/>
<uses-native-library
android:name="libOpenCL.so"
android:required="false"/>
</application>
Step 2: Pick a model from litert-community
Choose a .litertlm file from litert-community on Hugging Face. Start with
litert-community/gemma-4-E2B-it-litert-lm (the file gemma-4-E2B-it.litertlm,
2.6 GB). For a 0.6 GB model, start with litert-community/Qwen3-0.6B (the file
Qwen3-0.6B.litertlm). Both files run on the CPU and the GPU. A SoC suffix such
as _Google_Tensor_G5 or .mediatek.mt6993 marks an NPU build, which this
skill doesn't cover. The model card names the tested backends and the size.
You must read get a model before you choose a model file other than these two, before you writ
자주 묻는 질문
모델 파일을 앱 안에 넣을 수 있나요?
아니요. 모델 파일은 앱의 assets나 패키지가 아니라 기기 저장소에 있어야 합니다.
이미지나 오디오도 지원하나요?
아니요. 텍스트 모델만 다룹니다. 비전 모델과 오디오 모델은 다른 스킬에서 다룹니다.
어떤 모델과 함께 작동하나요?
.litertlm 형식의 공개 텍스트 모델, 예를 들어 Gemma, Qwen, Llama, Phi를 대상으로 합니다.
상세 정보
작성자의 원본 설명
Builds an Android app that runs an open text LLM on the device, on the CPU or the GPU, with the LiteRT-LM Kotlin API (com.google.ai.edge.litertlm:litertlm-android). Use this skill when creating a chat, summarization, or extraction feature with a .litertlm model from Hugging Face litert-community (Gemma, Qwen, Llama, Phi), including the Gradle dependency, the GPU manifest entries, getting the model file onto the device, Engine initialization off the main thread, a streamed multi-turn Conversation with sendMessageAsync, and the AndroidViewModel and Compose screen. Don't use for running .tflite v
repo: android/skills
인기도
- GitHub 스타
- 10k
- 순위
- #11911
- 라이선스
- Apache-2.0
- 업데이트
- 2026. 10. 29.
댓글
- …
이 저장소의 다른 스킬
agp-9-upgrade
10k에이전트가 Android 앱을 Android Gradle Plugin 9로 업그레이드하고 호환되지 않는 변경 사항을 처리하도록 돕습니다. 멀티플랫폼 프로젝트는 대상이 아닙니다.
camerax
10k에이전트가 CameraX로 동영상 녹화, 하드웨어 제어, ML Kit와 Media3 효과를 포함한 Android 카메라 기능을 만들도록 돕습니다.
android-for-cars-parked-apps
10k에이전트가 Android 동영상, 게임 또는 브라우저 앱을 Android Auto와 Android Automotive의 주차 중 앱으로 실행되도록 맞추는 것을 돕습니다.
appfunctions
10k에이전트가 Android 앱의 핵심 작업 흐름을 찾아, AI 에이전트와 음성 명령이 실행할 수 있는 AppFunctions로 노출하도록 돕습니다.
비슷한 스킬
android-clean-architecture
280k에이전트가 Android 프로젝트를 효율적으로 구성하도록 돕습니다. 유지보수와 새 기능 개발이 쉽도록 코드를 구조화합니다.
compose-multiplatform-patterns
280k에이전트가 KMP 프로젝트에서 Compose Multiplatform과 Jetpack Compose 패턴을 쓰도록 돕습니다. 상태, 내비게이션, 테마, 성능을 다룹니다.
dart-flutter-patterns
280kDart와 Flutter 앱용 코드를 작성하도록 에이전트를 돕습니다. 견고하고 관리하기 쉬운 앱을 만드는 현대적인 패턴을 씁니다.