简体   繁体   中英

React native build error: Attempt to invoke virtual method'boolean com.facebook.react.uimanager.FabricViewStateManager.hasStateWrappper()

My previous builds work fine, but now I'm getting this error when I try to take a build. I don't know how to resolve this error.

If anyone faces the same issue please help me out.

Attempt to invoke virtual method'boolean com.facebook.react.uimanager.FabricViewStateManager.hasStateWrappper()' on a null object reference

在此处输入图像描述

I was able to narrow down what was causing the error for me by using adb logcat and tracing the app.

The issue stemmed from both <Input> (from react-native-elements ) and <TextInput> (from react-native ). Both would cause the error, and the app would run without error if I commented out any Input/TextInput elements in the Componenets.

I wasn't quite able to get it to work with @kangear 's response, but it was close. After a lot of digging and testing, I was able to get the app to work properly with the following line of code in android\app\build.gradle , in dependencies section:

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

I tried just using implementation 'androidx.appcompat:appcompat:1.3.1' , but that wouldn't work either.

Hope this is able to save someone some time, as it took me quite a long time to figure it out!

I had same issue for this. do not use +

implementation "androidx.appcompat:appcompat:1.4.0-alpha01"

or

implementation "androidx.appcompat:appcompat:+"

Correct way:(lower than 1.4 )

implementation "androidx.appcompat:appcompat:1.1.0"

see here: https://github.com/facebook/react-native/issues/31572

update

./gradlew -q app:dependencies > 1.txt

maybe you can see this:

| +--- com.github.AnJiaoDe:TabLayoutNiubility:V1.1.6 | | \--- androidx.appcompat:appcompat:+ -> 1.4.0-alpha01 (*)

3rd lib content a androidx.appcompat:appcompat:+

so you must be:

implementation ('com.github.AnJiaoDe:TabLayoutNiubility:V1.1.6') {
exclude group: 'androidx.appcompat', module: 'appcompat'
}

android/app/build.gradle

paste the following code in dependencies section

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

I Solve This Error Simple way.
No.1) create new expo project expo init {yourProjectName}
No.2) Your previous project copy all your create folder and files and copy you will install dependencies command.
No.3) You New Project Paste all folder and files and install all previous dependencies.
Now you run Your Project npm start or yarn start .
I hope your problem solve.

Maybe you can update react-native version to 0.68.2 .

This worked for me.

Verify Gradle version: 7.0.2

Other solutions were not viable for me. Downgrading to appcompat to 1.3.1 is not a good solution. And upgrading to 0.68.2 is also quite an effort.

I instead

  • forked react-native version that I was on.
  • made the changes mentioned here
  • Re-built the ReactAndroid-release.aar by following this
  • place ReactAndroid-release.aar in android/app/libs

And now you can use Appcompat 1.4.x on any React native version. Tried on 0.64.3.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM