AI Dev Tools

Offline AI on Android with Gemma 4: PocketClaw Deep Dive

Imagine an AI assistant so powerful it lives entirely on your phone, no internet required. PocketClaw is here, and it's a glimpse into a truly decentralized AI future.

Screenshot of the PocketClaw Android app interface showing chat and file upload options.

Key Takeaways

  • PocketClaw is a fully offline AI assistant for Android, running on a 1.5 GB Gemma 4 E2B model.
  • The project bypasses cloud LLM issues like latency, cost, and network dependency.
  • It integrates on-device RAG for PDF querying and can perform native phone actions via intents.

What if the AI revolution wasn’t happening in some distant, humming server farm, but right here, in the palm of your hand? For years, we’ve been tethered to the cloud for our smarts – our chatbots, our image generators, our ever-more-sophisticated digital helpers. But what if that tether could snap? What if the next fundamental platform shift in computing wasn’t about more powerful clouds, but about reclaiming power for the edge – for us?

This isn’t a hypothetical. Manoj Raksh, a developer clearly fueled by more than just caffeine (and perhaps a healthy dose of disbelief in the status quo), has built PocketClaw, an Android AI assistant that runs fully offline. Think about that for a second. No internet. No latency. No per-call costs racking up in the background. Just pure, unadulterated AI intelligence, humming away on your device.

And how did he achieve this seemingly magical feat? By wrangling Gemma 4, specifically the E2B variant, into a mere 1.5 GB package. This is mind-boggling. We’re talking about a language model that can chat, understand photos, ingest PDFs, set alarms, toggle flashlights, send texts, and even search the web – all without ever needing to whisper to a distant server. It’s like fitting a supercomputer into a Swiss Army knife.

The Cloud’s Toll: Latency, Cost, and Fragility

For anyone who’s spent time building AI agents on cloud LLMs, Manoj’s pain points will resonate like a siren song. Latency is the silent killer of user experience. Every chained call, every hop across the network, adds precious milliseconds that can turn a fluid interaction into a stilted chore. Then there’s cost – a specter that looms larger with every surge in user traffic. And, of course, the ultimate indignity: a dropped network connection renders your entire sophisticated AI edifice useless.

This is where phones, these pocket-sized marvels of engineering we carry everywhere, become incredibly compelling. They offer a path to bypassing these cloud-induced ailments entirely. Model on the device? Check. No per-call cost? Check. Network independent? Double-check.

The primary gatekeeper, as Manoj points out with scientific precision, is RAM. Mid-range Android phones offer a sweet spot of about 1.5 to 2 GB of usable memory. This immediately rules out the larger, more capable Gemma 4 variants. We’re talking E4B (2.5 GB, pushing it), the 26B MoE (workstation territory), and the 31B dense (server-grade).

This leaves us with Gemma 4 E2B at ~1.5 GB. It’s a tight fit, but as Manoj has proven, it’s an absolutely viable one, especially with its built-in vision capabilities. The key here is INT4 quantization. Imagine compressing a high-definition movie down to a manageable file size without losing all the visual fidelity. That’s what INT4 does for AI models, reducing full precision (around 20 GB for E2B) down to a phone-friendly 1.5 GB. It’s the same magic Google uses for Gemini Nano on Pixel phones.

The Engine Under the Hood: flutter_gemma and LiteRT-LM

To make this happen, Manoj opted for flutter_gemma, a plugin that gracefully wraps Google’s MediaPipe LLM API and LiteRT-LM. Why this specific choice? It’s the only Flutter plugin that natively handles vision input for Gemma 4 on Android. Most alternatives, being ports of llama.cpp, skimp on the multimodal features. This convenience comes with a trade-off: an added 80 MB of native libraries in the APK. However, Manoj managed to trim the final release APK down to a still-respectable 152 MB by removing unused image generation and WebGPU runtimes – clever optimization.

// android/app/build.gradle.kts
packaging {
    jniLibs {
        excludes.addAll(listOf(
            // We never generate images, only consume them.
            "**/libimagegenerator_gpu.so",
            "**/libmediapipe_tasks_vision_image_generator_jni.so",
            // WebGPU is for browsers, useless on Android.
            "**/libLiteRtWebGpuAccelerator.so",
            "**/libLiteRtTopKWebGpuSampler.so"
        ))
    }
}

If vision isn’t your primary concern, you could likely shave off even more bulk by sidestepping MediaPipe altogether.

RAG on Device: Smarter Search, No Servers

But PocketClaw isn’t just about raw chat. It’s about bringing Retrieval-Augmented Generation (RAG) – that fancy term for giving AI access to external knowledge – to your device. This requires a second model: Gecko 110M for embeddings, a lean ~110 MB. Manoj chose Gecko over EmbeddingGemma 300M because its smaller footprint delivered comparable retrieval quality for PDFs up to a hundred pages. For larger document sets, this might differ, but for typical use cases, it’s a solid win.

The whole pipeline – from PDF extraction (Syncfusion), intelligent chunking (Manoj’s own code), embedding generation (Gecko), to vector storage (sqlite-vec with HNSW) – runs entirely on the device. It’s an ecosystem of intelligence, self-contained and silent.

Device Actions: The ‘Real World’ Interface

Where PocketClaw truly shines is its ability to interact with your phone’s native capabilities. Gemma’s role here is to act as a sophisticated intent classifier. You say, “set an alarm for 7:30 AM,” and Gemma outputs a structured JSON object specifying the tool and its parameters. Your Dart code then parses this, and a native Kotlin MethodChannel fires the appropriate Android intent. This allows for direct control over eight categories of actions: flashlight, alarms, dialer, SMS, calendar entries, location settings, web searches, and local notifications. Every single one of these actions happens without the LLM ever needing to know the network exists. It’s a beautiful, isolated loop of intelligence and action.

This isolated approach is key. Vanilla RAG works for simple, direct questions. “Who built PocketClaw?” is easily answered by retrieving a chunk containing your name. But real-world queries are messier. They require nuanced understanding, context, and the ability to synthesize information across different sources.

A Glitch in the Matrix (and How to Fix It)

And here’s where the real genius of this project, and the learning curve of building it, comes into play. Manoj encountered a common RAG failure mode: when the user’s query doesn’t perfectly align with the retrieved information. He describes a moment on Friday afternoon, after what he thought was a solid build, where he uploaded an LLM-focused PDF and asked Bottom line: it.

The system struggled. Instead of a coherent summary, it churned out a response that was nonsensical, highlighting a disconnect between the retrieved text and the model’s ability to synthesize it into a natural language summary.

This is the frontier of on-device AI. It’s not just about getting the model to run; it’s about making it truly useful for complex, human-centric tasks. The initial implementation of RAG, while functional, failed to bridge the gap between document chunks and coherent summarization for a non-trivial document. This isn’t a knock on Gemma or PocketClaw; it’s a proof to the ongoing challenges in making AI truly understand and interact with complex information, even on our most personal devices.

This is the next battleground: making these offline models not just able to perform tasks, but to perform them with the nuance and intelligence we expect from their cloud-bound cousins. Manoj’s work here isn’t just an impressive technical feat; it’s a foundational step towards a future where powerful AI isn’t a privilege of connectivity, but a right of computation.

The Future is On-Device

PocketClaw is a stunning demonstration. It’s a harbinger of an era where our devices become truly intelligent partners, capable of incredible feats without bleeding our data or draining our wallets through cloud subscriptions. It’s a powerful argument for a decentralized AI future, one where privacy and control are paramount. The implications for app development, for user privacy, and for the very definition of a ‘smart’ device are profound. We’re moving beyond mere apps; we’re building little intelligent beings that live on our phones, ready to assist, no matter the network conditions. And that, my friends, is utterly, wonderfully exciting.


🧬 Related Insights

Ji-ho Park
Written by

Korean developer ecosystem reporter tracking Kakao, Naver, LINE engineering blogs, and Korean open source contributions.

Worth sharing?

Get the best Developer Tools stories of the week in your inbox — no noise, no spam.

Originally reported by dev.to

Stay in the loop

The week's most important stories from DevTools Feed, delivered once a week.