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

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

Closed
EmmanuelSalazarID opened this issue Mar 23, 2022 · 7 comments

Comments

@EmmanuelSalazarID
Copy link

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"
    ]
  }
}
@charliecruzan-stripe
Copy link
Collaborator

Can you try RN 0.66? If not you may have to rely on the workaround here- https://stackoverflow.com/questions/67683149/react-native-build-error-attempt-to-invoke-virtual-methodboolean-com-facebook

@EmmanuelSalazarID
Copy link
Author

EmmanuelSalazarID commented Mar 23, 2022

Can you try RN 0.66? If not you may have to rely on the workaround here- https://stackoverflow.com/questions/67683149/react-native-build-error-attempt-to-invoke-virtual-methodboolean-com-facebook

I already tried with that version in another project

"react": "17.0.2",
"react-native": "0.66.3"

The error only occurs when installing stripe, when I remove it the error disappears

@charliecruzan-stripe
Copy link
Collaborator

all it takes is installing stripe? you don't need to modify the Javascript code at all? If you can share a link to repo that reproduces the error that would be very helpful

@EmmanuelSalazarID
Copy link
Author

all it takes is installing stripe? you don't need to modify the Javascript code at all? If you can share a link to repo that reproduces the error that would be very helpful

Yes, just installing stripe and using the component you get the error only on android

This is the repo
https://github.com/EmmanuelSalazarID/stripe-test

@EmmanuelSalazarID
Copy link
Author

@charliecruzan-stripe could you replicate the error?

@charliecruzan-stripe
Copy link
Collaborator

Yeah, it's caused by React Native- facebook/react-native#31572 (comment)

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

@CliffAw
Copy link

CliffAw commented 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:

// TODO: Remove after upgrade to React Native 0.68
implementation ("androidx.appcompat:appcompat:1.3.1") {
version {
strictly '1.3.1'
}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants