◉GEMINI LABJP
●NEON — Gemini 4 Neon went GA on 11/18, paid tier only, at $3.00 input / $15.00 output per 1M tokens●OFFICE — Since the same day you can pass Word, PowerPoint and Excel files straight to the API and pay only for the pages or sheets you pick●GEMINI 2.5 — gemini-2.5-pro and gemini-2.5-flash shut down on the API on 12/1, 12 days left●OAUTH — Users report that Gemini CLI's older sign-in route now fails without telling you why●AG IDE — Neon is now Antigravity's default, with a setup that plans on Neon and builds on Hydrogen●STRUCTURED — When Structured Output JSON breaks, check the schema, then the prompt, then your validator●NEON — Gemini 4 Neon went GA on 11/18, paid tier only, at $3.00 input / $15.00 output per 1M tokens●OFFICE — Since the same day you can pass Word, PowerPoint and Excel files straight to the API and pay only for the pages or sheets you pick●GEMINI 2.5 — gemini-2.5-pro and gemini-2.5-flash shut down on the API on 12/1, 12 days left●OAUTH — Users report that Gemini CLI's older sign-in route now fails without telling you why●AG IDE — Neon is now Antigravity's default, with a setup that plans on Neon and builds on Hydrogen●STRUCTURED — When Structured Output JSON breaks, check the schema, then the prompt, then your validator
Articles/API / SDK
◈ API / SDK/2026-08-20Advanced

Never hand Gemini a raw ANR thread dump

An ANR dump came in at 96 threads and 33,616 characters. Keeping only main cuts 98 percent, but it also deletes the thread that caused the block. Here is a lock-chain preprocessor, measured three ways.

gemini-api291android9anrdebugging4prompt-engineering16

✦ Premium Article

The morning after I pushed a staged rollout to 5 percent, Play Console Vitals showed one new ANR.

As an indie developer, that 5 percent window always feels short. You watch for about a day, then decide whether to continue or halt. A crash is manageable — the Crashlytics stack trace usually points somewhere. An ANR turned out to be a different animal.

The dump I opened listed 96 threads.

The 5 percent window doesn't leave time to read

I ship in stages: 5 percent, then 25, 50, and 100, watching Crash-free users and the ANR rate before each step. On the crash side I already have a preprocessor that de-obfuscates the trace before Gemini ever sees it, and that pipeline has held up well — I wrote about how it came together in handing Gemini an obfuscated stack trace.

So I tried the same move with the ANR dump: paste the whole thing, ask what happened. It didn't work. Every answer came back as some variation of "the main thread appears to be waiting on I/O" — things you could say without looking at the dump at all.

The problem was in how I was handing it over.

An ANR dump is a thread inventory, not a stack trace

A crash trace is one call stack. The thing to read is already narrowed down to a single path.

An ANR is different. The event is "the main thread failed to respond in time," so the system dumps the state of every thread in the process. In a real app carrying ad SDKs, an image loader, Firebase, and coroutine dispatchers, that lands somewhere between several dozen and well over a hundred.

What matters is that the dump also encodes relationships between threads.

"main" prio=5 tid=1 Blocked
  - waiting to lock <0x0e3a41c8> (a net.dolice.wallpapers.data.AssetIndex) held by thread 27
  at net.dolice.wallpapers.data.AssetIndex.lookup(AssetIndex.java:184)
  at net.dolice.wallpapers.ui.GridAdapter.onBindViewHolder(GridAdapter.java:96)

That single waiting to lock <address> ... held by thread 27 line is an edge between main and thread 27. If thread 27 is itself waiting on another lock, the edge extends further.

The cause of an ANR lives at the end of that chain. Main's own frames only record the fact that it is waiting.

✦

Thank you for reading this far.

Continue Reading

What follows includes implementation code, benchmarks, and practical content we hope you'll find useful. This site runs without ads — server and development costs are supported entirely by members like you. If it's been helpful, we'd be truly grateful for your support.

WHAT YOU'LL LEARN
✦You will be able to decide what to keep and what to drop from an ANR dump using a single rule: the chain of lock waits
✦You will understand why a main-thread-only preprocessor silently discards the root cause, so you avoid building one and discovering the gap in production
✦You will be able to drop a preprocessor into your own tooling that reduces a 96-thread, 33,616-character dump to 3 threads and 1,898 characters
Secure payment via Stripe · Cancel anytime
✦

Unlock This Article

Get full access to the rest of this article. Buy once, read anytime. This site is ad-free — your support goes directly toward keeping it running.

or
Unlock all articles with Membership →
Share

Thank You for Reading

Gemini Lab is ad-free, supported entirely by members like you. We publish practical guides daily with implementation code, benchmarks, and production-ready patterns. If you've found it useful, we'd love to have you on board.

  • ✦Copy-paste ready implementation code
  • ✦New advanced guides published daily
  • ✦$5/mo or $10 for lifetime access
View Membership →

Related Articles

◈ API / SDK2026-06-23
Integrating Gemini 3.2 Pro Function Calling into iOS/Android Apps: Production Design Patterns
A practical guide to integrating Gemini 3.2 Pro Function Calling into iOS and Android apps. Includes working SwiftUI, Kotlin, and Python code, plus production patterns proven in a real indie wallpaper app — cost, latency, staged rollout, and regression testing.
◈ API / SDK2026-05-16
Automating Firebase Crashlytics Analysis with Gemini API — A Real-World Implementation from an Indie App
A real-world implementation record of automating Firebase Crashlytics log analysis with Gemini API, validated during development of an indie wallpaper app (v2.1.0). Includes Before/After code for a RecyclerView crash fix and a production cost breakdown.
◈ API / SDK2026-04-29
Dynamic Few-Shot for Gemini API — A Self-Improving Prompt That Picks Examples by Vector Search
Hand-picked, hard-coded few-shot examples stop scaling once your inputs drift. This guide builds a Gemini Embeddings + vector search pipeline that selects the best 3-5 examples per request and grows them from production feedback, with copy-paste code.