From 0858d4120df242196570f5394f8ae4e623533493 Mon Sep 17 00:00:00 2001 From: fabriziobertoglio1987 Date: Tue, 21 Jul 2020 11:12:20 +0200 Subject: [PATCH] Fix Drawable Runtime - More Info in Description The AppCompat Theme Theme.AppCompat.Light.NoActionBar provides a default Drawable resource for AppCompatEditText. The resource is located in @drawable/abc_edit_text_material.xml https://chromium.googlesource.com/android_tools/+/7200281446186c7192cb02f54dc2b38e02d705e5/sdk/extras/android/support/v7/appcompat/res/drawable/abc_edit_text_material.xml A Runtime Error is triggered in a scenario with the following conditions: 1) Rendering a large number of TextInputs in the screen with a key prop 2) Triggering re-render with setInterval The scenario is also experienced with FlatList and ONLY using TextInput component. The following Runtime Error is triggered: NullPointerException:tempt to invoke virtual method 'android.graphics.drawable.Drawable android.graphics.drawable.Drawable$ConstantState.newDrawable(android.content.res.Resources) It is caused from the following line from abc_edit_text_material.xml I posted a Minimal Reproducible Example at https://github.com/facebook/react-native/issues/17530#issuecomment-660017858 This commit simply changes RNTester to use a custom drawable resource for TextInput named @drawable/edit_text. --- .../android/app/src/main/AndroidManifest.xml | 2 +- .../app/src/main/res/drawable/edit_text.xml | 28 +++++++++++++++++++ .../app/src/main/res/values/styles.xml | 4 +-- 3 files changed, 31 insertions(+), 3 deletions(-) create mode 100644 RNTester/android/app/src/main/res/drawable/edit_text.xml diff --git a/RNTester/android/app/src/main/AndroidManifest.xml b/RNTester/android/app/src/main/AndroidManifest.xml index d47ee519ae3180..83b69d1f4ad42d 100644 --- a/RNTester/android/app/src/main/AndroidManifest.xml +++ b/RNTester/android/app/src/main/AndroidManifest.xml @@ -30,7 +30,7 @@ android:banner="@drawable/tv_banner" android:icon="@drawable/launcher_icon" android:label="@string/app_name" - android:theme="@style/Theme.ReactNative.AppCompat.Light" > + android:theme="@style/AppTheme"> + + + + + + + + + + diff --git a/RNTester/android/app/src/main/res/values/styles.xml b/RNTester/android/app/src/main/res/values/styles.xml index 62fe59fa485459..e0800ee36e0c58 100644 --- a/RNTester/android/app/src/main/res/values/styles.xml +++ b/RNTester/android/app/src/main/res/values/styles.xml @@ -1,9 +1,9 @@ - - +