Studio, Profilers & Firebase Quiz
BUILD & TOOLING › Delivery
What is the primary mechanism by which a baseline profile speeds up app startup?
- It compresses the APK so that less data is read from disk at launch
- ART AOT-compiles listed hot methods at install, skipping JIT warm-up
- It preloads every one of the app's classes into memory at device boot
- It completely disables the garbage collector during the very first launch
Answer: ART AOT-compiles listed hot methods at install, skipping JIT warm-up
Baseline profiles list hot code paths so ART can AOT-compile them at install time, skipping the interpret-then-JIT warm-up that otherwise slows early launches.
Which dependency configuration is the correct, recommended way to add LeakCanary?
- implementation 'com.squareup.leakcanary:leakcanary-android'
- releaseImplementation 'com.squareup.leakcanary:leakcanary-android'
- debugImplementation 'com.squareup.leakcanary:leakcanary-android'
- androidTestImplementation 'com.squareup.leakcanary:leakcanary-android'
Answer: debugImplementation 'com.squareup.leakcanary:leakcanary-android'
LeakCanary is added with debugImplementation so it auto-installs in debug builds only and never ships to production; no initialization code is required.
Roughly how long must an object stay reachable after being watched before LeakCanary treats it as retained and dumps the heap?
- 5 seconds
- 100 milliseconds
- 1 minute
- Immediately, on the next frame
Answer: 5 seconds
ObjectWatcher waits about 5 seconds (and triggers a GC) before considering a still-reachable watched object retained, then captures a heap dump for Shark to analyze.
Which profiler capture is best suited to finding what is retaining objects and causing a memory leak?
- Callstack sample
- System trace
- Network inspection
- Heap dump
Answer: Heap dump
A heap dump is a memory snapshot showing live objects and their reference chains, which is what you need to identify retained objects and their retaining references.
What is the role of the Firebase Bill of Materials (BoM) in an Android build?
- It authenticates the app with Firebase servers each time it starts up
- It pins compatible Firebase versions so you omit each library's version
- It generates the google-services.json file for your project automatically
- It removes unused Firebase code from the release APK during packaging
Answer: It pins compatible Firebase versions so you omit each library's version
The Firebase BoM is a platform dependency that fixes compatible versions across all Firebase artifacts, so each product is declared without its own version number.
Which tool and rule are used to generate a baseline profile?
- Microbenchmark test with BenchmarkRule for timing code
- Espresso test with ActivityScenarioRule for UI flows
- Macrobenchmark test with BaselineProfileRule
- Robolectric test with the Paparazzi plugin for snapshots
Answer: Macrobenchmark test with BaselineProfileRule
Baseline profiles are produced by a Macrobenchmark test using BaselineProfileRule.collect, which drives startup and user journeys to record the hot code paths.
Why does Android Studio's low-overhead profiling use a profileable (release-based) build rather than a debug build?
- Debug builds can’t connect to a physical device over ADB.
- Profileable builds add less overhead, so timings stay realistic.
- Heap dumps and allocation tracking only work on profileable builds.
- Release builds are required to capture network traffic in profiling.
Answer: Profileable builds add less overhead, so timings stay realistic.
A profileable build is based on the release variant and profiles with low overhead, so timings better reflect production; debuggable profiling is needed only for allocation tracking and heap dumps, which it cannot do.
You need to change a feature's behavior for users in production without shipping a new build or going through review. Which Firebase product is designed for this?
- Crashlytics, by attaching custom key-value pairs onto crash reports
- Cloud Messaging, by pushing a silent data message to every device
- Remote Config, serving server-set values the app fetches at runtime
- App Distribution, by sending an updated APK build to all of the testers
Answer: Remote Config, serving server-set values the app fetches at runtime
Remote Config lets you define parameters server-side that the app fetches and activates at runtime, so behavior and rollouts can change without a new release.
Your release build is minified with R8, and Crashlytics stack traces show obfuscated class and method names. What makes them human-readable?
- The Crashlytics Gradle plugin uploads the R8 mapping file for deobfuscation
- Crashlytics disables R8 minification automatically for every build it instruments
- Adding the firebase-bom dependency embeds the symbol table directly in the APK
- Remote Config downloads the mapping file to the device during the first app launch
Answer: The Crashlytics Gradle plugin uploads the R8 mapping file for deobfuscation
The Crashlytics Gradle plugin uploads the R8/ProGuard mapping file at build time, letting the Crashlytics console map obfuscated names back to the original symbols.
Users report occasional stutter while scrolling a list, but average CPU looks fine. Which profiler capture best pinpoints the dropped frames and what is blocking the main thread?
- A Java/Kotlin memory allocation record captured across the scroll session
- A heap dump snapshot compared against an earlier memory baseline
- Network inspector request-and-response timings across the session
- A system trace of frame rendering and main-thread scheduling over time
Answer: A system trace of frame rendering and main-thread scheduling over time
A system trace visualizes per-frame rendering, thread scheduling, and main-thread work across time, which is exactly what is needed to find jank and what stalls the UI thread.
What is the key trade-off between a Callstack Sample (sampled) capture and a Method Trace (instrumented) capture in the CPU profiler?
- Sampling can run only on emulators, while instrumentation requires a physical device
- Sampling polls cheaply but misses brief calls; instrumentation logs all at high cost.
- Sampling requires a debuggable build, while instrumentation works on release builds
- Sampling measures memory allocations, while instrumentation measures only wall-clock time
Answer: Sampling polls cheaply but misses brief calls; instrumentation logs all at high cost.
Sampled traces poll the call stack at intervals for low overhead but may miss brief calls; instrumented traces log every entry and exit for exact counts and timing at a much higher performance cost.
Beyond a baseline profile, what does adding a startup profile do at build time?
- It lets R8 group startup code together in the DEX files for faster loading
- It encrypts the baseline.prof so it cannot be tampered with on device
- It uploads startup timings to Firebase Performance Monitoring automatically
- It forces ART to interpret startup code so the JIT can profile it more accurately
Answer: It lets R8 group startup code together in the DEX files for faster loading
A startup profile is consumed by R8 to optimize DEX layout, placing startup classes and methods close together so they load faster, adding roughly a further 15% startup gain on top of the baseline profile.
After LeakCanary dumps the heap, what does the Shark analyzer compute to help you find the cause of a leak?
- The total bytes allocated since process start, summed across all threads
- A flame graph of CPU time spent during the leak window and heap dump
- The UI thread frame rate while the object was retained in memory
- The shortest strong-reference path from a GC root to the object
Answer: The shortest strong-reference path from a GC root to the object
Shark walks the heap dump to find the shortest path of strong references from a GC root to the retained object, producing the leak trace that points at what is holding it.
Your QA team needs to install signed pre-release builds on their own devices before the app goes to the Play Store. Which Firebase product is built for that?
- Cloud Messaging, by silently pushing the new build to testers
- Remote Config, by toggling a flag that swaps the installed binary
- App Distribution, for sending pre-release builds to testers
- Crashlytics, by attaching the build artifact to release notes
Answer: App Distribution, for sending pre-release builds to testers
Firebase App Distribution exists to hand out pre-release (debug or release) builds to named testers quickly, outside the Play Store release flow.