xref: /aosp_15_r20/external/leakcanary2/docs/getting_started.md (revision d9e8da70d8c9df9a41d7848ae506fb3115cae6e6)
1# Getting started
2
3To use LeakCanary, add the `leakcanary-android` dependency to your app's `build.gradle` file:
4
5```groovy
6dependencies {
7  // debugImplementation because LeakCanary should only run in debug builds.
8  debugImplementation 'com.squareup.leakcanary:leakcanary-android:{{ leak_canary.release }}'
9}
10```
11
12**That's it, there is no code change needed!**
13
14Confirm that LeakCanary is running on startup by filtering on the `LeakCanary` tag in [Logcat](https://developer.android.com/studio/command-line/logcat):
15
16```
17D LeakCanary: LeakCanary is running and ready to detect leaks
18```
19
20!!! info
21    LeakCanary automatically detects leaks of the following objects:
22
23    * destroyed `Activity` instances
24    * destroyed `Fragment` instances
25    * destroyed fragment `View` instances
26    * cleared `ViewModel` instances
27    * destroyed `Service` instance
28
29What's next? Learn the [Fundamentals](fundamentals.md)!
30