Kotzilla : Koin & Kotzilla Platform

The Complete Guide to Android Startup ANR Diagnosis

Written by Miguel Valdes-Faura | 27 Nov 2026

An Android startup ANR happens when your app's main thread stays busy during launch for longer than the system allows, so Android shows the "Application Not Responding" dialog or records an ANR before your first screen is ready. To diagnose one, you find which ANR type fired, read the main thread stack for startup frames such as ActivityThread.handleBindApplication, measure how long startup takes, and trace the slow work back to the code that runs in Application.onCreate() and your first activity.

TL;DR: Startup time counts toward the timeout of several ANR types. A slow Application.onCreate() can cause broadcast, service, and content provider ANRs, even when the code in the receiver or service is fast.

Platform behavior comes from the official Android documentation, and production diagnosis from the Kotzilla documentation and codelab. Each number links to its source.

Quick facts

Fact Value Source
Input dispatch timeout 5 seconds Android Developers
Broadcast receiver timeout, foreground intent 10 s (Android 13 and lower), 10 to 20 s (Android 14 and higher) Android Developers
Execute service timeout 20 s (foreground service), 200 s (background service) Android Developers
Google Play bad behavior threshold, user-perceived ANR rate 0.47% of daily active users overall, 8% on a single device model Android vitals
Google Play "excessive" startup Cold start 5 s or longer, warm start 2 s or longer Android vitals
Kotzilla Platform thresholds Slow cold start 3,500 ms, slow warm start 1,500 ms, screen not responding 4,500 ms, slow component on the main thread 100 ms Kotzilla Console docs

The Android timeouts above apply to AOSP and Pixel devices. They can vary by device manufacturer.

What is an Android startup ANR?

An Android startup ANR is an ANR that fires while your app is still launching. An ANR (Application Not Responding) is an error Android raises when an app's UI thread is blocked for too long. The UI thread is also called the main thread.

Startup matters because Android includes the cold start time in the timeout for several ANR types. A cold start is when the system creates your app's process from scratch, then creates the Application object, the main activity, and the first frame (App startup time).

Which ANR types can startup cause?

Five ANR types are sensitive to startup. The Diagnose and fix ANRs guide describes each one:

ANR type Default timeout How startup causes it
Input dispatch: no focused window 5 s The app takes too long to draw its first frame, so no window can receive key events.
Input dispatch 5 s Work in Application.onCreate() or the first activity blocks the main thread while the user taps.
Broadcast receiver Foreground: 10 to 20 s
Background: 60 to 120 s
(Android 14 and higher)
The cold start counts toward the timeout.
Execute service Foreground: 20 s
Background: 200 s
The timeout includes the cold start.
Content provider not responding Set by the calling app with ContentProviderClient.setDetectNotResponding The remote app's cold start counts toward the query time.

Which startup ANRs affect your Google Play ranking?

Google Play counts only ANRs of type Input dispatching timed out as user-perceived. User-perceived ANR rate is a core vital. When at least 0.47% of your daily active users have a user-perceived ANR, your app may be less discoverable on all devices (ANRs in Android vitals).

Background ANRs, such as a slow broadcast during a cold start, still appear in your ANR rate. They show as dialogs only when Show all ANRs is on in Developer options (ANRs).

How do you confirm that an ANR comes from startup?

You confirm a startup ANR by reading the stack of the unresponsive thread and looking for startup frames. Follow these steps.

01

Start with the ANR cluster signature

Open the ANR in Google Play Console or Firebase Crashlytics. The cluster signature lists the top frames suspected of causing the ANR (Diagnose and fix ANRs). If Crashlytics labels it "root cause unknown", see fixing Android ANRs when Crashlytics shows "root cause unknown".

The subject line tells you the ANR type. For example, Executing service com.example.app/MyService is a service timeout. For broadcasts, cmp= names the receiver class and act= names the intent.

02

Find the unresponsive thread

The thread to read depends on the ANR type (Find the unresponsive thread):

  • Input dispatch, execute service, foreground service start: main thread.
  • Synchronous broadcast receiver: the thread that runs onReceive(). This is the main thread unless you passed a handler to Context.registerReceiver.
  • Content provider not responding: a binder thread for a slow query, or the main thread for a long app startup.
03

Look for startup frames on the main thread

These frames on the main thread point to startup (Diagnose and fix ANRs):

  • ActivityThread.handleBindApplication: the app is still starting.
  • MyApplication.onCreate(): your own initialization code is still running.
  • handleCreateService, handleBindService, or handleServiceArgs: the service callbacks themselves are slow.

Note: For broadcast, service, and content provider clusters, a main thread stack showing nativePollOnce or "main thread idle" doesn't clear the main thread. The work may be on another thread, so read the other threads in the dump.

04

Follow locks and binder calls to the real cause

The blocked thread often waits on something else. Look for two patterns (Find the unresponsive thread):

  • Lock contention: a line such as Waiting for ... held by <thread name>. Find the thread that holds the lock and read its stack.
  • Slow binder call: BinderProxy.transactNative or BinderProxy.transact. The next lines name the system API being called.
05

Pull the raw traces when you need more detail

On a test device, you can pull ANR traces with adb (ANRs):

adb root
adb shell ls /data/anr          # newer releases write one anr_* file per ANR
adb pull /data/anr/<filename>

In production, ApplicationExitInfo reports exit reasons, including ANRs, on Android 11 (API level 30) and higher. When a report has no stack frames, the stack dump timed out or the process died. Use a Perfetto trace to check whether the main thread was running or waiting.

How do you measure startup time?

You measure startup with two metrics (App startup time):

  • Time to initial display (TTID): the time to draw the first frame. Android reports it for you.
  • Time to full display (TTFD): the time until the app is usable. You report it by calling reportFullyDrawn().

To read TTID locally, search Logcat for Displayed, or run:

# -S stops the app first, so you measure a cold start
adb shell am start -S -W com.example.app/.MainActivity \
  -c android.intent.category.LAUNCHER -a android.intent.action.MAIN

The output includes TotalTime. For repeatable numbers in CI, use the Macrobenchmark library with StartupTimingMetric. For a full trace, open Perfetto, find the Android App Startups slice, and look at operations such as bindApplication that take longer than 20 ms (App startup analysis and optimization).

To follow cold and warm startup from real user sessions, see continuous Android startup metrics in the Kotzilla Platform.

How do you find the root cause when the stack isn't enough?

A stack dump shows where the main thread was when the ANR fired. It can arrive late or empty, and it rarely names the class that made startup slow. For slow cold starts and screens that stop responding, the Kotzilla Platform records the startup itself. The session timeline shows each step until the first frame, the Koin components created on the main thread with their timings, and the gaps no event explains. If the main thread waited for a background thread building the same object, the Kotzilla MCP Server points to it.

For broadcast, service and content provider ANRs, start with the stack and ApplicationExitInfo steps above.

Example: a cold start with a frozen first screen

The Kotzilla codelab is a version of Google's Now in Android app with startup problems added on purpose. One cold start shows all three:

01
Application.onCreate() works for 6.5 seconds
No activity can start until this work ends, and Kotzilla reports a slow cold start. When a push or a broadcast wakes the app, the same work counts toward the broadcast and service timeouts.
02
A ViewModel freezes the first screen
MainActivityViewModel takes about 5 seconds to create on the main thread. Its dependencies resolve in milliseconds, so the time is in its constructor. The first screen stays blocked past 4.5 seconds, and Kotzilla flags it as not responding. On a real device, a tap during that wait turns it into an input dispatch ANR.
03
A worker blocks inside the startup window
A WorkManager worker takes about 2 seconds to create on a background thread. It starts from Application.onCreate(), so it still adds to the cold start.

The report lists five problems: a slow cold start, a slow screen, a screen not responding, a blocked main thread and a blocked background thread. All five come from these three components inside the startup window. One prompt to your AI coding agent, connected to the Kotzilla MCP Server, finds and fixes them: "My cold startup is over 10 seconds. Find everything that blocks it and fix it." Comparing the version before the fix with the version after shows which issues are gone.

If a gap in the timeline holds code that Koin does not create, such as SDK calls in onCreate(), wrap the suspects with KotzillaSDK.trace("name") { ... } and they appear in the timeline (Kotzilla SDK API).

For the same method on a production app, read how Bankin' cut ANRs by 78%.

Which code causes startup ANRs most often?

The same causes come back across the apps we monitor. Before they turn into ANRs, they make startup and screens slower:

  • Heavy ViewModel init: settings or data loaded in init {}
  • Session and login classes built on the main thread
  • Analytics, consent and other SDKs set up on the main thread
  • Storage (DataStore, preferences, database) opened at launch
  • Locks: the main thread waits for a background thread building the same object

On low-end phones and TV boxes, the same delays cross the ANR threshold. More detail on each cause: Fix Android ANRs from production data.

How do you fix a startup ANR?

You fix a startup ANR by doing less work on the main thread before the first frame. Together, the Android and Kotzilla docs recommend five changes:

01
Load data after the ViewModel is created
Don't read settings or data in init {} or the constructor. Start that work in viewModelScope on Dispatchers.IO and expose a StateFlow that starts in a loading state, so the first screen draws right away (Kotzilla: main thread performance).
02
Initialize lazily
Create objects when your code first needs them (App startup time). Koin creates singletons lazily by default, so keep that behavior: request services such as analytics or remote config with inject(), so Koin creates them on first use instead of through createdAtStart() or an early get() call (Kotzilla: slow app startup).
03
Move work to background threads
Run heavy computation with Dispatchers.Default (Kotzilla: main thread performance) and I/O with withContext(Dispatchers.IO) (ANRs).
04
Split heavy components
Break large components into smaller modules and isolate optional ones, so the main thread resolves less at launch (Kotzilla: slow app startup).
05
Draw the first frame early
Show the UI with placeholder data, then load bitmaps and other resources (App startup time). A fast first frame is also the fix for the no focused window ANR.

For lock contention, the Android docs suggest a coroutine Mutex, because a suspended coroutine leaves the main thread free (ANRs). With Koin, a common case is a single built on a background thread during startup while the first screen asks for it on the main thread. Making it lazy doesn't help, because the background thread has already started building it. Change what warms it up in the background, or make its constructor cheaper.

For a production example, read how Canal+ cut app startup time by 40% on low-memory devices, after Baseline Profiles were already in place.

How do you catch startup ANR risks before release?

You catch most risks by finding main thread work before it ships: in debug builds, after each fix, and at build time.

Turn on StrictMode in debug builds

StrictMode.ThreadPolicy flags expensive operations, such as disk and network access, on the main thread. This setup crashes debug builds on each violation, so every violation gets attention (App startup analysis and optimization):

class MyApplication : Application() {
    override fun onCreate() {
        super.onCreate()
        if (BuildConfig.DEBUG)
            StrictMode.setThreadPolicy(
                StrictMode.ThreadPolicy.Builder()
                    .detectAll()     // disk reads, disk writes, network, and more
                    .penaltyDeath()  // crash so the violation is visible
                    .build()
            )
    }
}

Check your content providers

Android creates content providers before Application.onCreate(), in an undetermined order, and each one is expensive to create. The App Startup library replaces many providers with one and lets you set the order of initialization.

Verify each fix on a fresh session

A fix that looks right in the code can still leave work on the main thread. When your AI coding agent applies a fix through the Kotzilla MCP Server, it rebuilds the app, runs it and checks a fresh session. It verifies that the pattern is gone, for example that the component is off the main thread or no longer created at startup, and compares the timing with the same issue on the same machine (Kotzilla MCP Server).

Gate the release at build time

The Kotzilla Gradle plugin prints a report for your app version at the end of each build. To stop a release that brings back a slow startup or a frozen screen, turn that report into a build gate (Kotzilla build report):

kotzilla {
    skipBuildReportFailure = false   // fail the build when the report status is FAIL
}

A passing report, an app version with no data yet, and network errors never fail the build.

Where each tool helps

Tool Best for Limit to know
Google Play Console (Android vitals) ANR rate, cluster signatures, and slow start rates from real users Reports the stack captured at the ANR, and stack dumps can arrive late or empty
Firebase Crashlytics ANR cluster signatures alongside crashes Same stack-based view, with the same late or empty dumps
Perfetto and Android Studio Profiler Full startup traces on a test device Runs on devices you control
StrictMode Main thread disk and network access in debug builds Debug builds only
Kotzilla Platform Slow cold and warm starts and screens that stop responding in production, with the Koin components that block the main thread Flags screens blocked over 4.5s. Component-level detail requires Koin

The Kotzilla SDK captures sessions, cold and warm startup, crashes, screen render times and screens that stop responding for any Android app from SDK 2.3.0. The dependency graph and main thread component issues require Koin (Kotzilla FAQ). For a wider comparison, see performance monitoring beyond Firebase for Kotlin apps.

Frequently asked questions

What usually causes an Android startup ANR?

Slow work on the main thread before the first frame: in Application.onCreate(), or while the first screen creates its ViewModels and their dependencies. In the apps we monitor, a slow ViewModel is the most common case. When the work is in Application.onCreate(), the stack shows ActivityThread.handleBindApplication on the main thread.

Why does a broadcast receiver ANR point to my Application class?

Because the cold start counts toward the broadcast receiver timeout. If Application.onCreate() is slow, the receiver can run out of time before onReceive() starts.

What does a "no focused window" ANR mean at startup?

It means your app took too long to draw its first frame, so no window could receive key events within 5 seconds. Reduce startup work so the first frame draws sooner.

How do I tell a startup ANR from a regular ANR?

Read the main thread stack. Startup ANRs show ActivityThread.handleBindApplication or your Application.onCreate() method.

Can the Kotzilla Platform measure what happens before Application.onCreate?

Yes. From SDK 2.3.0, early start boots the SDK at process start through a ContentProvider or an AndroidX Startup initializer, before Application.onCreate(), so it captures early crashes and startup timing. It's on by default (Kotzilla early start).

What's next?

Start with the data you already have: open your ANR clusters in Play Console and search the main thread stacks for handleBindApplication. Then turn on StrictMode in your debug build and measure your cold start with adb shell am start -S -W.

To see which components slow down your startup in production, start with the Kotzilla Platform's free developer plan, then fix slow startups and frozen screens with your AI coding agent through the Kotzilla MCP Server. The Kotzilla codelab reproduces the example from this guide on the Now in Android app, so you can try the full flow on a sample app first.

Published November 24, 2026. Last updated November 24, 2026.