Lorixen.
EN

Baseline Profiles: faster Android app start-up

Short answer: When an Android app opens for the first time after install or update, much of its code runs in a slower interpreted or just-in-time compiled mode. A Baseline Profile is a list of the classes and methods your app needs at start-up and in key journeys, shipped with the app so Android can compile them ahead of time. Generate one with the Macrobenchmark library and the Baseline Profile Gradle plugin, include it in release builds, measure cold start before and after, and regenerate it as the app changes.

Why Android apps start slowly at first

Android apps are distributed as bytecode. On the device, the Android Runtime (ART) decides how to execute it: it can interpret code, compile it just in time while the app runs, or compile it ahead of time. Over days of use, ART learns which code is hot and optimises it, so apps tend to get faster after a while.

The problem is the first impression. A fresh install, or the first launch after an update, runs before ART has learned anything. That's when customers are most likely to judge the app as slow, and when a business app's first screen, such as a login or a booking list, matters most.

What Baseline Profiles do

Android's documentation explains that a Baseline Profile lists code paths so that ART can optimise them through ahead-of-time (AOT) compilation, providing improvements for every new user and every app update. It describes this as a form of profile-guided optimisation for start-up and interactions. Google's documentation says Baseline Profiles improve code execution speed by about 30% from the first launch for the included code paths, by avoiding interpretation and JIT compilation steps. Treat that as Google's own figure and measure your app's results yourself.

Many Jetpack libraries, including Compose, already ship their own profiles. Your app's profile covers your own code: the start-up path, the main screens and the most common journeys.

Android also offers Startup Profiles, which its documentation describes as similar but used at compile time to optimise the DEX layout for faster start-up.

How to generate one

Android's guide recommends using the Macrobenchmark module template and the Baseline Profile Gradle plugin, starting from recent Android Studio and Android Gradle Plugin versions, and generating profiles automatically for every release using the Jetpack Macrobenchmark library and BaselineProfileRule.

In outline:

  1. Add a baseline profile module using Android Studio's template. It sets up the Gradle plugin and a generator test.
  2. Write the journey. The generator test launches the app and walks through the critical path: start-up, then perhaps opening the main list, a detail screen and search. Use the same UI automation you'd use for tests.
  3. Run the generator on a device or emulator. It records which classes and methods were used and writes a profile file, such as baseline-prof.txt, into your app module's sources.
  4. Build the release app. The profile is packaged into the release build, and devices use it to compile those paths ahead of time on install.

The documentation notes a practical check: open the generated text profile and confirm the class and method names are unobfuscated, which tells you it was generated from the right build configuration.

Measure before and after

Don't assume. Android's tooling includes Macrobenchmark for measuring start-up and rendering:

  • Write a start-up benchmark that measures cold start time.
  • Run it with the profile disabled and enabled, on a real mid-range device rather than a flagship.
  • Repeat several times and compare median values.

If the improvement is small, check that your journey covers the code that actually runs at start-up, and that the profile is included in the build you're testing.

Pick the journeys that matter to customers

Profiles should follow what people do in the first seconds and most often:

  • A shop app: launch, home feed, product page, basket.
  • A booking app: launch, login, upcoming bookings, booking detail.
  • A field-service app: launch, today's jobs, job detail, photo capture.

Covering every screen isn't the goal; covering the critical path well is.

Keep it up to date

Code changes with every release, so a profile generated months ago drifts. Make generation part of the release process:

  1. Run the generator in CI or before each release.
  2. Commit the updated profile file.
  3. Run the start-up benchmark to catch regressions.

Treat a large jump in cold start time as a release blocker, the same way you would a crash.

Watch real-world start-up too

Lab benchmarks tell you about one device; your customers have hundreds. Google Play Console's Android vitals reports start-up times from real users, and many performance-monitoring tools record app launch times by device and version. Check them after each release to confirm the profile is helping in the field, and look for particular device models that remain slow.

Other start-up improvements still matter

A profile speeds up code that has to run; it doesn't remove unnecessary work. Also:

  • Defer initialising SDKs that aren't needed on the first screen.
  • Avoid blocking the main thread with disk or network work at launch.
  • Show useful content quickly, with cached data where possible.
  • Keep the app lean with code shrinking, which works alongside profiles.

A worked example

Consider a hypothetical Liverpool gym-chain app whose first launch after each update felt sluggish, and some members complained in store reviews. The developer added a baseline profile module, wrote a generator journey covering launch, login, the class timetable and booking a class, and added a cold start benchmark. On a mid-range test phone the first-launch time improved noticeably, and the team now regenerates the profile and runs the benchmark before every release.

FAQ

Does this work for apps written with Jetpack Compose?

Yes. Compose ships its own profiles, and your app's profile adds your screens and logic.

Do cross-platform apps benefit?

It depends on the framework and how much code runs on ART. Check your framework's documentation.

Does the profile make the app bigger?

The profile file is small. The benefit is compiled code on the device for the paths it lists.

If your Android app feels slow to open, especially after updates, ask us to profile its start-up.

Sources

WhatsAppBook a call