diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/textinput/BUCK b/ReactAndroid/src/main/java/com/facebook/react/views/textinput/BUCK index dae8c212ad0913..2ce3100e90fc45 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/textinput/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/views/textinput/BUCK @@ -13,6 +13,7 @@ rn_android_library( ], deps = [ YOGA_TARGET, + react_native_dep("libraries/fbcore/src/main/java/com/facebook/common/logging:logging"), react_native_dep("third-party/java/infer-annotations:infer-annotations"), react_native_dep("third-party/java/jsr-305:jsr-305"), react_native_target("java/com/facebook/react/bridge:bridge"), diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputManager.java b/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputManager.java index 5788161bd28512..60392088f26a6a 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputManager.java @@ -27,6 +27,7 @@ import android.view.View; import android.view.inputmethod.EditorInfo; import android.widget.TextView; +import com.facebook.common.logging.FLog; import com.facebook.infer.annotation.Assertions; import com.facebook.react.bridge.JSApplicationIllegalArgumentException; import com.facebook.react.bridge.ReactContext; @@ -64,7 +65,7 @@ */ @ReactModule(name = ReactTextInputManager.REACT_CLASS) public class ReactTextInputManager extends BaseViewManager { - + public static final String TAG = ReactTextInputManager.class.getSimpleName(); protected static final String REACT_CLASS = "AndroidTextInput"; private static final int[] SPACING_TYPES = { @@ -464,9 +465,14 @@ public void setUnderlineColor(ReactEditText view, @Nullable Integer underlineCol // Drawable.mutate() can sometimes crash due to an AOSP bug: // See https://code.google.com/p/android/issues/detail?id=191754 for more info Drawable background = view.getBackground(); - Drawable drawableToMutate = background.getConstantState() != null ? - background.mutate() : - background; + Drawable drawableToMutate = background; + if (background.getConstantState() != null) { + try { + drawableToMutate = background.mutate(); + } catch (NullPointerException e) { + FLog.e(TAG, "NullPointerException when setting underlineColorAndroid for TextInput", e); + } + } if (underlineColor == null) { drawableToMutate.clearColorFilter();