diff --git a/library/leakcanary-android/src/main/java/com/squareup/leakcanary/AndroidExcludedRefs.java b/library/leakcanary-android/src/main/java/com/squareup/leakcanary/AndroidExcludedRefs.java index 7dfc03bb3a..0853d59abb 100644 --- a/library/leakcanary-android/src/main/java/com/squareup/leakcanary/AndroidExcludedRefs.java +++ b/library/leakcanary-android/src/main/java/com/squareup/leakcanary/AndroidExcludedRefs.java @@ -172,6 +172,13 @@ public static ExcludedRefs.Builder createAppDefaults() { excluded.instanceField("android.animation.LayoutTransition$1", "val$parent"); } + if (SDK_INT >= JELLY_BEAN || SDK_INT <= LOLLIPOP_MR1) { + // SpellCheckerSessionListenerImpl.mHandler is leaking destroyed Activity when the + // SpellCheckerSession is closed before the service is connected. + // Tracked here: https://code.google.com/p/android/issues/detail?id=172542 + excluded.instanceField("android.view.textservice.SpellCheckerSession$1", "this$0"); + } + if (MOTOROLA.equals(MANUFACTURER) && SDK_INT == KITKAT) { // DevicePolicyManager keeps a reference to the context it has been created with instead of // extracting the application context. In this Motorola build, DevicePolicyManager has an @@ -215,14 +222,6 @@ public static ExcludedRefs.Builder createAppDefaults() { excluded.staticField("android.widget.TextView", "mLastHoveredView"); } - if (MOTOROLA.equals(MANUFACTURER) && SDK_INT == JELLY_BEAN) { - // android.view.textservice.SpellCheckerSession$SpellCheckerSessionListenerImpl.mHandler is - // a GC root, it's an inner class that references SpellCheckerSession which itself references - // a SpellChecker through SpellCheckerSession.mSpellCheckerSessionListener. - excluded.instanceField("android.view.textservice.SpellCheckerSession", - "mSpellCheckerSessionListener"); - } - if (SAMSUNG.equals(MANUFACTURER) && SDK_INT == KITKAT) { // android.app.LoadedApk.mResources has a reference to // android.content.res.Resources.mPersonaManager which has a reference to