{
  "id": 20743831,
  "title": "Building Offline AI on Android: 5 LiteRT-LM Pitfalls and Fixes",
  "url": "https://urgent.news/2026/11/19/building-offline-ai-on-android-5-litert-lm-pitfalls-and-fixes",
  "topic": "ai",
  "section": "AI",
  "published": "2026-11-19T08:23:24.000Z",
  "source": {
    "name": "HackerNoon",
    "slug": "hackernoon",
    "url": "https://hackernoon.com/building-offline-ai-on-android-5-litert-lm-pitfalls-and-fixes?source=rss"
  },
  "original_language": null,
  "account": "This story discusses the challenges faced when building an offline-first Large Language Model (LLM) chat application on Android using the LiteRT-LM runtime. Five key issues are identified, along with their solutions:\n\n1. Using the GPU delegate can cause the app to be killed due to excessive memory allocation. The solution is to stick with the CPU as the default and use an opt-in experimental GPU switch with fallback mechanisms.\n\n2. The dlopen() function fails for OpenCL libraries on Android 12+ despite their existence. This can be fixed by declaring the required libraries in AndroidManifest.xml with required=\"false\" to ensure installation on devices lacking the libraries.\n\n3. Naive chat templates can serialize JSON into the conversation context, poisoning subsequent turns. Two strategies are recommended: creating a content-safe version of templates during session creation and running a sanitizer on generated text before persisting it to the database.\n\n4. Bundle files exported for the LiteRT-LM SDK can be version-fragile, causing compatibility issues between different runtime versions. It is advised to include a minRuntimeVersion field in the model JSON and regenerate bundles when updating the SDK.\n\n5. The Engine and Conversation objects are not thread-safe, leading to potential use-after-free crashes. All native interactions should be wrapped with a Mutex, and proper synchronization mechanisms, such as an AtomicInteger of in-flight native operations, should be implemented to prevent concurrent access issues.\n\nThe article also presents performance measurements for the LiteRT-LM model, showing that warm-up times vary depending on the device and runtime version. The native container load phase is identified as the primary factor affecting initialization time.",
  "summary": "Production lessons from shipping an offline-first LLM chat app on Android with Google LiteRT-LM: GPU delegate OOMs, dlopen failures, thermal throttling and their fixes.",
  "summary_source": "publisher",
  "key_points": [],
  "editors_take": null,
  "opinion": false,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "outlets_capped": false,
    "also_reported_by": []
  },
  "machine_translated": false,
  "ai_generated": true,
  "disclaimer": "Accounts, briefs, key points, the editor’s take and translations are written by software from other outlets’ reporting and may contain errors. A summary whose summary_source is \"publisher\" is the outlet’s own feed text. Always check the linked original."
}