diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index ab7e66a09a0fa4e1023d09ef51a748f6a7d3ef0a..217b0b162f6a1d66b9dda8df296e7abe3faef731 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -1747,9 +1747,10 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
 
     @UsedForTesting
     /* package for test */ DistracterFilter createDistracterFilter() {
-        return new DistracterFilter(this /* Context */,
+        // Return an empty distracter filter when this method is called before onCreate().
+        return (mRichImm != null) ? new DistracterFilter(this /* Context */,
                 mRichImm.getMyEnabledInputMethodSubtypeList(
-                        true /* allowsImplicitlySelectedSubtypes */));
+                        true /* allowsImplicitlySelectedSubtypes */)) : new DistracterFilter();
     }
 
     public void dumpDictionaryForDebug(final String dictName) {