Studio, Profilers & Firebase Flashcards

BUILD & TOOLING › Delivery

What is a baseline profile and how does it improve performance?
A list of hot code paths (classes/methods) shipped in the AAB so ART can AOT-compile them at install time instead of relying on interpretation plus JIT. This removes the runtime warm-up, improving startup and reducing jank, typically around 30% faster from the first launch.
How do you generate a baseline profile?
Write a Macrobenchmark test using BaselineProfileRule.collect, driving the app through startup and key user journeys (often via UiAutomator). The Baseline Profile Gradle Plugin runs it on a device/emulator and outputs rules that are compiled into baseline.prof packaged in the app's assets.
How does LeakCanary detect a memory leak?
ObjectWatcher wraps destroyed objects (Activities, Fragments, views, ViewModels) in weak references. If one stays reachable about 5 seconds after a GC, it is flagged as retained, LeakCanary dumps the heap, and the Shark analyzer computes the shortest reference chain from a GC root to the leaked object.
How do you add LeakCanary, and does it run in release builds?
Add a single debugImplementation dependency on leakcanary-android; no code changes are needed. Because it is debug-only it never ships in release builds, so it adds no production overhead.
When would you use a system trace versus a heap dump?
Use a system trace to investigate CPU, scheduling, rendering, and jank over time across threads. Use a heap dump to capture a memory snapshot and find what objects are alive and what is retaining them, i.e. for leaks and high memory usage.
What is the difference between profileable and debuggable profiling?
Profileable profiling runs a release-based build (manifest profileable shell=true, API 29+) with low overhead but no Java/Kotlin allocation tracking or heap dumps. Debuggable profiling uses the debug build and enables full data like allocations and heap dumps, at a higher performance cost.
What is the Firebase BoM and why use it?
The Firebase Bill of Materials (firebase-bom) is a platform dependency that pins compatible versions of all Firebase libraries. You import the BoM once and declare each product without a version, so the BoM guarantees the artifacts work together.
What three pieces wire Firebase into an Android build?
The google-services.json config file in the app module, the Google services Gradle plugin (com.google.gms.google-services) that reads it, and the Firebase SDK dependencies (usually via the BoM). Crashlytics additionally needs the Crashlytics Gradle plugin for symbol upload.
What does a startup profile add on top of a baseline profile?
A startup profile is a focused subset of startup-only rules used at build time by R8 to optimize the DEX layout (Dex Layout Optimizations), placing startup code together. Combined with a baseline profile it yields roughly an extra 15% startup improvement.

Back to Studio, Profilers & Firebase