I used to wonder why my Flutter app felt sluggish during development but noticeably smoother in profile and release mode. Then I came across something interesting about how Android optimizes applications — and it made me rethink what happens when we ship an app for the first time.

There is something interesting about mobile app development that I think many developers have experienced.

You spend days or weeks building an application. You carefully design the UI, optimize your widgets, manage state, reduce unnecessary rebuilds, and make sure everything feels smooth.

Then you run your application in debug mode.

And suddenly, everything feels slow.

Screen transitions aren’t as smooth as you expected. Loading takes longer. Sometimes even scrolling feels a little uncomfortable.

You switch to profile mode or build a release APK, and things become noticeably better.

At first, I thought it was simply Flutter’s debug-mode overhead. And, to be fair, that is a big part of the explanation.

But recently, I came across a video explaining another interesting performance problem on Android: why applications can be at their slowest on the day they are released.

That introduced me to something called Baseline Profiles.

And it was worth understanding.

The phone is learning how to run your application

Here’s an interesting thing about Android.

Android doesn’t necessarily compile every part of an application into optimized machine code immediately when the application is installed.

Instead, its runtime, ART (Android Runtime), uses different compilation strategies.

It can interpret code, compile frequently executed methods using JIT (Just-In-Time) compilation, and collect information about which parts of an application are used most frequently.

Over time, Android learns how your application behaves.

Think of it as taking notes.

The more someone uses your application, the more information the system collects about frequently executed methods. It can then use those profiles to optimize performance.

That’s a clever approach.

But there is a catch.

What happens when someone installs your application for the first time?

The phone hasn’t learned anything about how that particular application is used yet.

It doesn’t have the same usage history as someone who has been using it for months.

This means the first experience may not benefit from all the optimizations that become available over time.

And that’s where things get interesting.

Every update can start the learning process again

Imagine you have an application with thousands of users.

They have been using it for months. Android has collected information about frequently executed methods and optimized the application based on those profiles.

Then you release a new update.

Some of the previous compilation information may no longer be applicable because the application code has changed.

Android may need to collect new information and optimize the updated code again.

This creates an interesting challenge.

Your existing users might experience performance differences after an update, even though the update was intended to improve the application.

Wouldn’t it be better if Android already knew which parts of your application were important before users started interacting with it?

Well, that’s exactly the problem Baseline Profiles are designed to address.

Meet Baseline Profiles

A Baseline Profile is essentially a predefined profile containing information about important classes and methods that should be optimized.

Instead of waiting for users to interact with your application and allowing Android to learn everything from scratch, developers can provide this information ahead of time.

The profile is packaged with the application.

When the application is installed, Android can use that information to optimize important code paths earlier.

In simple terms:

Without a Baseline Profile, Android learns which parts of your application matter through usage.

With a Baseline Profile, developers can tell Android which parts matter before users even open the application.

That’s a significant difference in how we approach first-launch performance.

Why not compile everything?

You might be wondering:

If compiling important code improves performance, why doesn’t Android simply compile everything during installation?

Interestingly, Android has already experimented with approaches involving extensive ahead-of-time compilation.

But compiling everything comes with trade-offs:

  • Installation can take longer.
  • Compiled code consumes additional storage.
  • Unnecessary code may be loaded into memory.
  • Not every part of an application is equally important.

An application might contain thousands of methods, but users don’t necessarily execute all of them.

Optimizing everything isn’t always the smartest solution.

The better approach is to identify the code paths that matter most.

And that’s the philosophy behind Baseline Profiles.

How do developers generate Baseline Profiles?

This is where things become practical.

Android developers can use the AndroidX Baseline Profile Gradle plugin and a dedicated profile-generation module.

The idea is relatively straightforward:

  1. Define important user journeys using UI automation tests.
  2. Run those tests on a device.
  3. Let the tooling collect information about the code paths executed.
  4. Generate a Baseline Profile.
  5. Package that profile with the application.

For example, imagine you’re developing an e-commerce application.

You might create a test that:

  • Launches the application.
  • Opens the home screen.
  • Scrolls through products.
  • Opens a product details page.
  • Adds an item to the cart.
  • Proceeds toward checkout.

These are important journeys because they represent interactions that users are likely to perform.

The generated profile can help Android optimize the code involved in those journeys.

The important thing is to generate profiles based on real application behavior, not arbitrary code execution.

Three things that can quietly go wrong

Generating a Baseline Profile doesn’t automatically guarantee that everything is working correctly.

There are a few things developers should pay attention to.

1. R8 obfuscation

Production Android applications often use R8 to shrink, optimize, and obfuscate code.

Since R8 can rename classes and methods, profile information needs to remain correctly mapped to the optimized application.

The official tooling handles much of this process, but it’s worth checking the generated and packaged profile rather than assuming everything is correct.

2. Profile size

Bigger doesn’t necessarily mean better.

A Baseline Profile should focus on important code paths rather than attempting to include everything.

Keeping the profile under approximately 1.5 MB, as oversized profiles can run into platform or tooling limitations.

3. Outdated profiles

Applications evolve.

New features are introduced, navigation changes, and old code gets replaced.

A profile generated several months ago might no longer represent the most important user journeys.

That’s why regenerating profiles as part of your development or CI/CD process is a good practice.

How do you know whether it’s actually working?

This is probably one of my favourite parts of the video.

Instead of simply assuming that the profile is working, you can inspect Android’s compilation information using ADB.

For example:

adb shell dumpsys package dexopt | grep -A 2 com.fluttx.reader 

Replace the package name with your own application ID.

Look for compilation information such as speed-profile.

It indicates profile-guided compilation.

For a proper performance comparison, you should also benchmark your application with and without Baseline Profiles, measuring things like cold startup time.

After all, performance optimization should be measured, not assumed.

What about Flutter developers?

This is where I started thinking about my own Flutter projects.

Flutter has three primary build modes:

  • Debug: Uses Dart JIT compilation and enables development and debugging features.
  • Profile: Uses Dart AOT compilation while retaining performance instrumentation.
  • Release: Uses Dart AOT compilation with production optimizations.

That’s why a Flutter application often feels considerably slower in debug mode than in profile or release mode.

But there’s another important distinction.

Flutter’s Dart AOT compilation and Android’s ART optimization are not the same thing.

Even though Flutter compiles Dart code ahead of time, an Android application still relies on native Android components, the Android runtime, framework interactions, and potentially several native plugins.

Baseline Profiles can help optimize relevant Android-side execution paths.

They don’t directly optimize Dart widget rebuilding, expensive database queries, or inefficient application logic.

For a Flutter application, it’s worth investigating both sides:

  • Flutter performance: widget rendering, application initialization, asynchronous operations, memory usage, and Dart execution.
  • Android performance: application startup, native plugin initialization, Android framework interactions, and Baseline Profiles.

This distinction is important because not every performance problem has the same solution.

A small change in perspective

I used to think that if my application performed well in release mode, I had probably done enough performance optimization.

But this topic reminded me that performance isn’t just about how an application behaves after someone has used it for a while.

It’s also about the very first experience.

The first time someone taps your application icon.

The first screen they see.

The first interaction they make.

That experience matters, especially when you’re releasing an application to users who have never installed it before.

And as developers, we should be thinking about that experience before the application reaches the Play Store.

The goal isn’t just to make an application fast after Android has learned how to run it. The goal is to help it feel fast from the very beginning.

Further Learning

I learned about this topic from a video that explains ART compilation, Cloud Profiles, Baseline Profiles, profile generation, common pitfalls, and performance verification.

Watch the original video: Why Your Android App Is Slowest on Launch Day — Baseline Profiles Explained

If you’re an Android or Flutter developer, Tell me what you will do after learning this? Does your app need baseline profling?