React Native - Android crashes when install a dependency and use TextInput

See original GitHub issue

When I called the TextInput element it crashes on android. It gives me an error when a I tried to use stripe on my app. it gives me the next following error:

E/unknown:ReactNative: Exception in native call
    java.lang.NullPointerException: Attempt to invoke virtual method 'boolean com.facebook.react.uimanager.FabricViewStateManager.hasStateWrapper()' on a null object reference
        at com.facebook.react.views.textinput.ReactEditText.updateCachedSpannable(ReactEditText.java:981)
        at com.facebook.react.views.textinput.ReactEditText.access$300(ReactEditText.java:75)
        at com.facebook.react.views.textinput.ReactEditText$TextWatcherDelegator.onTextChanged(ReactEditText.java:1092)
        at android.widget.TextView.sendOnTextChanged(TextView.java:11785)
        at android.widget.TextView.setText(TextView.java:6965)
        at android.widget.TextView.setText(TextView.java:6761)
        at android.widget.EditText.setText(EditText.java:145)
        at android.widget.TextView.setText(TextView.java:6713)
        at android.widget.TextView.setEditableFactory(TextView.java:6670)
        at androidx.emoji2.viewsintegration.EmojiEditTextHelper$HelperInternal19.<init>(EmojiEditTextHelper.java:268)
        at androidx.emoji2.viewsintegration.EmojiEditTextHelper.<init>(EmojiEditTextHelper.java:109)
        at androidx.appcompat.widget.AppCompatEmojiEditTextHelper.<init>(AppCompatEmojiEditTextHelper.java:52)
        at androidx.appcompat.widget.AppCompatEditText.<init>(AppCompatEditText.java:110)
        at androidx.appcompat.widget.AppCompatEditText.<init>(AppCompatEditText.java:91)
        at androidx.appcompat.widget.AppCompatEditText.<init>(AppCompatEditText.java:87)
        at com.facebook.react.views.textinput.ReactEditText.<init>(ReactEditText.java:126)
        at com.facebook.react.views.textinput.ReactTextInputManager.createViewInstance(ReactTextInputManager.java:180)
        at com.facebook.react.views.textinput.ReactTextInputManager.createViewInstance(ReactTextInputManager.java:81)
        at com.facebook.react.uimanager.ViewManager.createViewInstance(ViewManager.java:139)
        at com.facebook.react.uimanager.ViewManager.createView(ViewManager.java:76)
        at com.facebook.react.uimanager.NativeViewHierarchyManager.createView(NativeViewHierarchyManager.java:281)
        at com.facebook.react.uimanager.UIViewOperationQueue$CreateViewOperation.execute(UIViewOperationQueue.java:194)
        at com.facebook.react.uimanager.UIViewOperationQueue$DispatchUIFrameCallback.dispatchPendingNonBatchedOperations(UIViewOperationQueue.java:1110)
        at com.facebook.react.uimanager.UIViewOperationQueue$DispatchUIFrameCallback.doFrameGuarded(UIViewOperationQueue.java:1081)
        at com.facebook.react.uimanager.GuardedFrameCallback.doFrame(GuardedFrameCallback.java:29)
        at com.facebook.react.modules.core.ReactChoreographer$ReactChoreographerDispatcher.doFrame(ReactChoreographer.java:175)
        at com.facebook.react.modules.core.ChoreographerCompat$FrameCallback$1.doFrame(ChoreographerCompat.java:85)
        at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1008)
        at android.view.Choreographer.doCallbacks(Choreographer.java:809)
        at android.view.Choreographer.doFrame(Choreographer.java:740)
        at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:995)
        at android.os.Handler.handleCallback(Handler.java:938)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:246)
        at android.app.ActivityThread.main(ActivityThread.java:8653)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:602)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1130)

Screenshot_20220323-103325_stripeTest

This is the versions of my dependencies

"@stripe/stripe-react-native": "^0.4.0",
"react": "17.0.2",
"react-native": "0.67.4"
package.json

{
  "name": "stripetest",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "android": "react-native run-android",
    "ios": "react-native run-ios",
    "start": "react-native start",
    "test": "jest",
    "lint": "eslint . --ext .js,.jsx,.ts,.tsx"
  },
  "dependencies": {
    "@stripe/stripe-react-native": "^0.4.0",
    "react": "17.0.2",
    "react-native": "0.67.4"
  },
  "devDependencies": {
    "@babel/core": "^7.12.9",
    "@babel/runtime": "^7.12.5",
    "@react-native-community/eslint-config": "^2.0.0",
    "@types/jest": "^26.0.23",
    "@types/react-native": "^0.66.15",
    "@types/react-test-renderer": "^17.0.1",
    "@typescript-eslint/eslint-plugin": "^5.7.0",
    "@typescript-eslint/parser": "^5.7.0",
    "babel-jest": "^26.6.3",
    "eslint": "^7.14.0",
    "jest": "^26.6.3",
    "metro-react-native-babel-preset": "^0.66.2",
    "react-test-renderer": "17.0.2",
    "typescript": "^4.4.4"
  },
  "resolutions": {
    "@types/react": "^17"
  },
  "jest": {
    "preset": "react-native",
    "moduleFileExtensions": [
      "ts",
      "tsx",
      "js",
      "jsx",
      "json",
      "node"
    ]
  }
}

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:7

github_iconTop GitHub Comments

5reactions
charliecruzan-stripecommented, Mar 25, 2022

Yeah, it’s caused by React Native- https://github.com/facebook/react-native/issues/31572#issuecomment-981523534

It will be fixed in RN 68, but until then you can add this workaround we have in our example app: https://github.com/stripe/stripe-react-native/blob/master/example/android/app/build.gradle#L203-L207

1reaction
CliffAwcommented, Aug 23, 2022

For anyone who still needs this, the above comment from @charliecruzan-stripe refers to the example build.gradle file, which has since changed, so the line numbers no longer match up.

The workaround can be found here: https://github.com/stripe/stripe-react-native/blob/b688e87aa4391708fc8683ab4b00c4d36f810117/example/android/app/build.gradle#L202-L207

Read more comments on GitHub >

github_iconTop Results From Across the Web

React Native fatal crashes on clicking textInput - Stack Overflow
So we fixed this by upgrading to React Native 0.56 and updating all our libraries and dependencies. This caused a whole host of...
Read more >
Known issues with Android Studio and Android Gradle Plugin
Native debugger crashes with "Debugger process finished with exit code 127" ... This error occurs on Linux-based platforms when starting the native debugger....
Read more >
Get Started with React Native - Visual Studio App Center
Let's get started with setting up App Center React Native SDK in your app to use App Center Analytics and App Center Crashes....
Read more >
Android Crashes When It Tries to Render TextInput - PSPDFKit
Android Crashes When It Tries to Render TextInput. This is a known React Native issue with version 0.64 and later. React Native 0.64...
Read more >
react-native-gesture-handler - npm
You will need to have an Android or iOS device or emulator connected as well as react-native-cli package installed globally. React Native ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found