Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android crashes when tried to render TextInput on RN 0.64.x and using appcompat library of 1.4.0 #31572

Closed
st1ng opened this issue May 22, 2021 · 23 comments
Labels
Needs: Author Feedback Resolution: Locked This issue was locked by the bot.

Comments

@st1ng
Copy link

st1ng commented May 22, 2021

Description

Latest 0.64 react-native is not compatible with latest appcompat androidx library. When app tries to render TextInput, NullPointerException thrown. This happens in file ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java (line 972):

private void updateCachedSpannable(boolean resetStyles) { // Noops in non-Fabric if (!mFabricViewStateManager.hasStateWrapper()) { return; }

This happens because super constructor AppCompatEditText calls updateCachedSpannable as part of construction, so mFabricViewStateManager not initialized yet and is null. So need to check mFabricViewStateManager for null value first.

React Native version:

System:
OS: macOS 10.15.7
CPU: (8) x64 Intel(R) Core(TM) i7-2600K CPU @ 3.40GHz
Memory: 790.90 MB / 24.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 15.4.0 - /usr/local/bin/node
Yarn: 1.22.10 - /usr/local/bin/yarn
npm: 7.0.15 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
Managers:
CocoaPods: 1.10.1 - /Users/st1ng/.rvm/gems/ruby-2.7.0/bin/pod
SDKs:
iOS SDK:
Platforms: iOS 14.4, DriverKit 20.2, macOS 11.1, tvOS 14.3, watchOS 7.2
Android SDK:
API Levels: 23, 25, 26, 27, 28, 29, 30
Build Tools: 25.0.0, 26.0.0, 27.0.3, 28.0.3, 29.0.2, 29.0.3, 30.0.0, 30.0.2
System Images: android-21 | Google APIs Intel x86 Atom_64, android-24 | Google Play Intel x86 Atom, android-29 | Google Play Intel x86 Atom, android-30 | Google Play Intel x86 Atom
Android NDK: Not Found
IDEs:
Android Studio: 4.2 AI-202.7660.26.42.7322048
Xcode: 12.4/12D4e - /usr/bin/xcodebuild
Languages:
Java: 1.8.0_221 - /usr/bin/javac
npmPackages:
@react-native-community/cli: Not Found
react: 17.0.1 => 17.0.1
react-native: 0.64.1 => 0.64.1

Steps To Reproduce

  1. Create empty project
  2. Set explicitly appcompat version to 1.4.0-alpha01 or make it "+" in app/build.gradle
    implementation "androidx.appcompat:appcompat:1.4.0-alpha01"
  3. Add empty TextInput to any page

Expected Results

No crash happen

Snack, code example, screenshot, or link to a repository:

Screenshot_1621715066

@safaiyeh
Copy link
Contributor

Hey @st1ng I want to learn your motivations needing to support androidx.appcompat:appcompat:1.4.0-alpha01 is there an API RN is not supporting that you need? If RN does not support the version (especially alpha versions) there isn't an expectation for it to be working.

@kangear
Copy link

kangear commented May 28, 2021

same problem

@wanderbon
Copy link

Same problem with any version of appcompat

@kangear
Copy link

kangear commented Jul 7, 2021

@ahsanjamilarkhitech
Copy link

still struggling with the issue. any solutions?

@cristianoccazinsp
Copy link
Contributor

Same issue with RN 0.65.1

@cristianoccazinsp
Copy link
Contributor

Use this for now:

implementation ("androidx.appcompat:appcompat:1.3.1") {
        version {
            strictly '1.3.1'
        }
    }

@jraska
Copy link

jraska commented Nov 26, 2021

Hi, androidx.appcompat:appcompat:1.4.0 is now stable and as such RN is now becoming a blocker to update further. Since many other androidx dependencies are transitively dependent on appcompat, the issue will soon start bubbling through many apps using RN.

Please does anyone have any idea how to solve this actually? The locking appcompat on version 1.3.1 is a temporary fix, but what should be the long term one?

@cortinico
Copy link
Contributor

I've addressed this in e21f8ec It will be available in the upcoming stable of RN

@mikehardy
Copy link
Contributor

Here I am chasing a crash bug down from stackoverflow and github and such and I find it closed just hours ago - thanks a bunch @cortinico ! I'm fine pinning the version in gradle as long as I know there's a fix coming, I'll just mark the pin for removal with react-native 0.68. Cheers

nawbc pushed a commit to NawbExplorer/react-native that referenced this issue Dec 7, 2021
Summary:
This Diff fixes a crash happening as the user uses AppCompat 1.4.0
as a dependency in their App and uses a `TextInput` component.

The crash happens as `mFabricViewStateManager` is accessed during
the ctor of the superclass, and is not yet initialized.

Fixes facebook#31572

Changelog:
[Android] [Fixed] - Fix crash on ReactEditText with AppCompat 1.4.0

Reviewed By: ShikaSD

Differential Revision: D32674975

fbshipit-source-id: efa413f5e33527a29fbcfa729e8b006ecb235978
tido64 added a commit to microsoft/react-native-test-app that referenced this issue Dec 8, 2021
The app crashes when trying to render `TextInput` with AppCompat Library
at v1.4.0. For more details, see the GitHub issue:
facebook/react-native#31572

This reverts commit 4c34c8c.
tido64 added a commit to microsoft/react-native-test-app that referenced this issue Dec 8, 2021
The app crashes when trying to render `TextInput` with AppCompat Library
at v1.4.0. For more details, see the GitHub issue:
facebook/react-native#31572

This reverts commit 4c34c8c.
marianeum pushed a commit to Skyscanner/react-native that referenced this issue Dec 20, 2021
Summary:
This Diff fixes a crash happening as the user uses AppCompat 1.4.0
as a dependency in their App and uses a `TextInput` component.

The crash happens as `mFabricViewStateManager` is accessed during
the ctor of the superclass, and is not yet initialized.

Fixes facebook#31572

Changelog:
[Android] [Fixed] - Fix crash on ReactEditText with AppCompat 1.4.0

Reviewed By: ShikaSD

Differential Revision: D32674975

fbshipit-source-id: efa413f5e33527a29fbcfa729e8b006ecb235978
@BANG88
Copy link

BANG88 commented Jan 6, 2022

Use this for now:

implementation ("androidx.appcompat:appcompat:1.3.1") {
        version {
            strictly '1.3.1'
        }
    }

Save my day!

@devildriver666
Copy link

devildriver666 commented Jan 31, 2022

This solution creating issue with all other libraries ( I am using tons in my project which are using all possible versions of appcompact)

implementation ("androidx.appcompat:appcompat:1.3.1") {
        version {
            strictly '1.3.1'
        }
    }

@RobTS
Copy link

RobTS commented Feb 6, 2022

Why is this issue marked as closed if it is very much alive?

@cortinico
Copy link
Contributor

Why is this issue marked as closed if it is very much alive?

Because the issue is solved on main + there is a workaround provided. Nothing else is actionable on this issue anymore 👍

@RobTS
Copy link

RobTS commented Feb 6, 2022

@cortinico my bad, I had just seen the reversal to 1.3.1 commit, not the other one!

@Bamorem
Copy link

Bamorem commented Mar 3, 2022

I have the same issue but don't use any androidx.appcompat:appcompat in my build.gradle

but when i search for it in my project i see this: MERGED from [androidx.appcompat:appcompat:1.4.1] /Users/[username]/.gradle/caches/transforms-3/0e660b8bafa777eda46724d78ef391ea/transformed/appcompat-1.4.1/AndroidManifest.xml:17:1-24:12

What should i do ?

@mikehardy
Copy link
Contributor

@Bamorem implement the workaround as described
#31572 (comment)

@danarchos
Copy link

danarchos commented Mar 8, 2022

Had this issue after upgrading to JDK 11, and upgrading targetSdkVersion and compleSdKVersion to 31 from 30 (React Native 0.64.3)

Thank you so much @cristianoccazinsp for the workaround that worked. Many many hours have been spent on this.

@patriziomadferitmilione
Copy link

Hi I have the same issue, but I don't have any iOS or Android folders in my project,

what should I do?

thanks for the help

@brentvatne
Copy link
Collaborator

@patriziomadferitmilione - download the latest version of expo go

@codal-mpawar
Copy link

@brentvatne @BANG88 @mikehardy @RobTS @kangear Hey guys Are we have any solution for this issue?

"react": "16.13.1",
"react-native": "0.64.3",

@mikehardy
Copy link
Contributor

@codal-mpawar please read comments prior to posting, resolution is either of:

  1. Android crashes when tried to render TextInput on RN 0.64.x and using appcompat library of 1.4.0 #31572 (comment) (pin appcompat to 1.3.1
  2. upgrade to react-native 0.68.2 - https://react-native-community.github.io/upgrade-helper/ (or apparently latest version of expo includes the fix as well, so if you use expo; upgrade expo)

This issue is completely resolved

adrianha pushed a commit to traveloka-archive/react-native that referenced this issue Sep 19, 2022
Summary:
This Diff fixes a crash happening as the user uses AppCompat 1.4.0
as a dependency in their App and uses a `TextInput` component.

The crash happens as `mFabricViewStateManager` is accessed during
the ctor of the superclass, and is not yet initialized.

Fixes facebook#31572

Changelog:
[Android] [Fixed] - Fix crash on ReactEditText with AppCompat 1.4.0

Reviewed By: ShikaSD

Differential Revision: D32674975

fbshipit-source-id: efa413f5e33527a29fbcfa729e8b006ecb235978

# Conflicts:
#	ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java
adrianha pushed a commit to traveloka-archive/react-native that referenced this issue Sep 19, 2022
Summary:
This Diff fixes a crash happening as the user uses AppCompat 1.4.0
as a dependency in their App and uses a `TextInput` component.

The crash happens as `mFabricViewStateManager` is accessed during
the ctor of the superclass, and is not yet initialized.

Fixes facebook#31572

Changelog:
[Android] [Fixed] - Fix crash on ReactEditText with AppCompat 1.4.0

Reviewed By: ShikaSD

Differential Revision: D32674975

fbshipit-source-id: efa413f5e33527a29fbcfa729e8b006ecb235978

# Conflicts:
#	ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java
@mfajarf
Copy link

mfajarf commented Nov 7, 2022

Use this for now:

implementation ("androidx.appcompat:appcompat:1.3.1") {
        version {
            strictly '1.3.1'
        }
    }

not working for me

@facebook facebook locked as resolved and limited conversation to collaborators Nov 29, 2022
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Nov 29, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Needs: Author Feedback Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests