To omit a class from being monitored by LeakCanary, you need to create a LeakCanaryExclusions
class and add the class that needs to be excluded from monitoring.
Here are the steps to do it:
LeakCanaryExclusions
.class MyLeakCanaryExclusions : LeakCanaryExclusions {
override fun excludeField(field: Field): Boolean {
// Add logic here to exclude any fields from class
// you want to exclude from LeakCanary monitoring
}
override fun excludeObject(className: String): Boolean {
// Add logic here to exclude any class from LeakCanary monitoring
}
}
LeakCanary
using the LeakCanary.config
builder.LeakCanary.config = LeakCanary.config.copy(
exclusions = MyLeakCanaryExclusions())
That's it! Any class or field that has been excluded in the MyLeakCanaryExclusions
class will not be monitored by LeakCanary
.
Asked: 2023-05-05 16:24:17 +0000
Seen: 11 times
Last updated: May 05 '23