use

This version of LeakCanary is particularly easy to use, simply adding the following dependencies. Nothing needs to be done and initialized in the application as in previous versions. If there is no special need, only the following dependence can be, is so magical, as for the principle of what can see the official website. You can also configure some special options, such as errors sent to the server, see the website for details. Leakcanary website

dependencies {
  // debugImplementation because LeakCanary should only run in debug builds.
  debugImplementation 'com. Squareup. Leakcanary: leakcanary - android: 2.0 - beta - 3'
}
Copy the code

Problems encountered in use

When I added the dependency, I clicked Run and reported an error

Unable to get provider leakcanary.internal.LeakCanaryFileProvider
Copy the code

I made an issue on LeakCanary’s GitHub and later a gay friend ran into the same problem as me and it turned out that we both used aspectjxAOP. So just add the following code to app.build:

aspectjx {
exclude 'com.squareup.leakcanary'
}
dependencies {
// Other dependencies
}
Copy the code

Clean Project -> Rebuild Project or invalidate cache/restart. Thank you very much for your gay friend.

There is a problem, if there is dependent on the previous leakcanary version, are likely to add debugImplementation ‘com. Squareup. Leakcanary: leakcanary – android: 2.0 – beta – 3’ will not add in, Invalidate cache/restart Found this to be a bit versatile. I hope it helps.