React NativeのTextInput
には、Androidで下線部の色を指定するunderlineColorAndroid
というpropsがありますが、これを指定すると以下のようなエラーを吐いてアプリがクラッシュする場合があります(エラーが起きない時もあります。)
Attempt to invoke virtual method 'android.graphics.drawable.Drawable android.graphics.drawable.Drawable$ConstantState.newDrawable(android.content.res.Resources)' on a null object reference
FlatList
, ScrollView
と同時に使用した際に発生するようです。
エラーが起きている箇所は ReactTextInputManager.java
で、underlineColorAndroid
のpropsを渡すと、ReactTextInputManager.setUnderlineColor
が呼ばれ、Drawable.mutate()
のバグでクラッシュします。
根本的な解決策はなく、underlineColorAndroid
の使用を避けるほか無いようです。
TextInput
の下線を消す際に利用すると思うのですが、下線を消したい場合はunderlineColorAndroid
の代わりに、android/app/src/main/res/values/styles.xml
を以下のように書き換えることで変更可能です。
styles.xml
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowExitAnimation">@android:anim/fade_out</item>
<item name="android:windowBackground">@drawable/splash_screen</item>
<item name="android:editTextBackground">@android:color/transparent</item>
</style>
</resources>