Debugging and Profiling Apps
Overview
Android Studio ships with a built-in Profiler that covers most day-to-day profiling needs — CPU, memory, network, and power. The standalone tools that used to fill this role are gone: Traceview is deprecated in favor of the CPU profiler, Hierarchy Viewer is deprecated in favor of the Layout Inspector, and the Android Device Monitor (monitor) was deprecated in Android Studio 3.1 and removed in Android Studio 3.2. Start with these tools:
- Android Studio Profiler - Record system traces, capture heap dumps, track Java/Kotlin allocations, and inspect network traffic and power usage from within the IDE.
- Layout Inspector - Inspect your app’s view hierarchy at runtime.
- System tracing with Perfetto - Platform-wide tracing tool introduced in Android 10; recommended over the legacy
systracecommand for devices running Android 10 and higher. - Profiling GPU Rendering - Quick visual representation of how much time it takes to render the frames of a UI window relative to the 16-ms-per-frame benchmark.
- Visualizing Overdraw - Shows on the device where an app might be doing more rendering work than necessary, helping you see where you might be able to reduce rendering overhead.
- LeakCanary - Library for finding memory leaks easily.
- Batterystats and Battery Historian - Shows where and how processes are drawing current from the battery, visualized on a timeline. Note that the Battery Historian repository was archived in December 2022.
- App performance overview - Google’s hub for app performance improvement guidance.
- Profiling Android Apps - Performance Tuning
- Vogella Android Analysis Tools
- Apptim: Free Tool to Profile and Visualize App Performance
Optimizing Performance
Check out the following links regarding optimizing performance:
- Layout Performance
- ViewHolder with ListView
- Drawables and Bitmaps
- Caching Bitmaps
- App Performance Guidance
- Managing App Memory
- Layout Performance Guide
- Keeping Your App Responsive