Back to Runanywhere Sdks

RunAnywhere AI — Android Example

examples/android/RunAnywhereAI/README.md

0.20.127.2 KB
Original Source

RunAnywhere AI — Android Example

<p align="center"> </p> <p align="center"> <a href="https://play.google.com/store/apps/details?id=com.runanywhere.runanywhereai"> </a> </p> <p align="center"> </p>

A production-ready reference app for the RunAnywhere Kotlin SDK. Chat, speech, vision, voice agents, RAG, and model management—all running on-device with privacy-first, offline-capable inference.


Requirements

ItemMinimum
Android StudioLatest stable (Ladybug or newer recommended)
Android SDKAPI 24+ (Android 7.0); compile/target SDK 37
JDK17
NDK & CMakeAs required by the repo root native build scripts
Disk spaceSeveral GB for native builds and downloaded AI models
DeviceARM64 physical device recommended; emulator supported for most features

Export ANDROID_HOME and ANDROID_NDK_HOME before building native libraries.


Setup

Important: This sample consumes four local AARs from libs/ (core, LlamaCPP, ONNX, QHexRT). A clean clone must build native libraries and stage SDK artifacts before the app will compile.

1. Clone and open the example

bash
git clone https://github.com/RunanywhereAI/runanywhere-sdks.git
cd runanywhere-sdks/examples/android/RunAnywhereAI

2. Build native libraries (repo root)

From the example directory, build the Android native core for your target ABI:

bash
../../../scripts/build/build-core-android.sh arm64-v8a

This produces the JNI libraries the Kotlin SDK packages expect. Re-run this step after any change to the C++ layer in runanywhere-commons.

3. Stage SDK AARs into libs/

bash
./scripts/stage-sdk-aars.sh debug

This builds the four Kotlin SDK modules (core, LlamaCPP, ONNX, QHexRT) against the staged natives and copies deterministic AAR names into libs/. Run again after SDK or native changes.

4. Verify and run

bash
./scripts/verify.sh

Or open the project in Android Studio and run the app configuration, or install from the command line:

bash
./gradlew :app:installDebug

After modifying the SDK

ChangeAction
C++ / commonsRe-run build-core-android.sh, then stage-sdk-aars.sh
Kotlin SDKRe-run stage-sdk-aars.sh
App UI onlyRebuild in Android Studio or ./gradlew :app:assembleDebug

Features

FeatureDescription
AI ChatStreaming LLM conversations with analytics and thinking-mode support
Speech-to-TextBatch and live transcription via Sherpa-ONNX / Whisper
Text-to-SpeechNeural Piper voices and system TTS fallback
Voice AssistantFull STT → LLM → TTS pipeline
Vision (VLM)Camera and image understanding
RAGDocument ingestion and on-device Q&A
Model ManagementDownload, load, unload, and delete models
StorageUsage overview and cache cleanup
SolutionsYAML pipeline demos synced from shared catalog
OfflineInference runs locally after models are downloaded

NPU / QHexRT (Snapdragon devices)

On supported Qualcomm Hexagon NPU hardware, the app can register the QHexRT backend for accelerated inference. The QHexRT AAR is included in the standard four-AAR staging flow.

To test private runanywhere/*_HNPU model bundles:

  1. Open Settings → Downloads.
  2. Enter a Hugging Face token and tap Save token.
  3. Download and load an HNPU model from the model picker. The SDK resolves the correct Hexagon architecture natively.
  4. Tap Clear to return to public, no-auth downloads.

The token is passed through the SDK at runtime; it is not stored in source, assets, or logs. Private QHexRT release and device-suite workflows live in a separate checkout—see your internal QHexRT documentation if you maintain that stack.


Project structure

RunAnywhereAI/
├── app/src/main/java/com/runanywhere/runanywhereai/
│   ├── RunAnywhereApplication.kt    # SDK init and backend registration
│   ├── ui/screens/                  # Feature screens (chat, voice, vision, …)
│   ├── ui/navigation/               # Compose navigation
│   ├── ui/theme/                    # Material 3 theming (#FF6900 brand)
│   └── data/                        # Model catalog, settings repositories
├── libs/                            # Staged SDK AARs (not committed on clean clone)
├── scripts/
│   ├── stage-sdk-aars.sh            # Build and copy AARs into libs/
│   ├── verify.sh                    # Strict debug APK build gate
│   └── smoke.sh                     # Fast SDK API coverage check
└── README.md

The app depends on local AARs rather than Maven coordinates so SDK changes in the monorepo are immediately testable.


Troubleshooting

SymptomFix
Missing libs/*.aarRun ./scripts/stage-sdk-aars.sh debug
Native link errors after commons changesRe-run ../../../scripts/build/build-core-android.sh arm64-v8a, then restage AARs
Gradle dependency verification failuresEnsure all four AARs are present; run ./scripts/verify.sh for the exact gate
QHexRT / NPU models unavailableConfirm device support and that the QHexRT AAR was staged; HNPU bundles require a saved HF token
Out of memory during native buildClose other Gradle daemons; the repo recommends limited workers for SDK builds

For a quick static check without a full compile:

bash
./scripts/smoke.sh

ResourceLink
Kotlin SDKsdk/runanywhere-kotlin/README.md
iOS exampleexamples/ios/RunAnywhereAI
React Native exampleexamples/react-native/RunAnywhereAI
Flutter exampleexamples/flutter/RunAnywhereAI
Play Storecom.runanywhere.runanywhereai
Discorddiscord.gg/N359FBbDVd
IssuesGitHub Issues
Email[email protected]

License

This project is licensed under the RunAnywhere License (Apache 2.0 based, with additional commercial-use terms). See LICENSE for details.