44

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

enter image description here

Lineu Pastorelli
  • 502
  • 1
  • 8
  • 20
Ashish Verma
  • 441
  • 1
  • 4
  • 4

6 Answers6

89

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!

Pavel Chuchuva
  • 22,633
  • 10
  • 99
  • 115
Kenneth Streit
  • 1,042
  • 9
  • 12
  • 25
    For anyone getting here after adding stripe to react native, it's `implementation(project(':stripe_stripe-react-native')) { exclude module: 'appcompat' }` as well as the above. – Jordan Robinson May 24 '22 at 11:54
  • @JordanRobinson comment works for me, using the last version of react native stripe, upgrading kotlinVersion to 1.6.0. Thanks, you save me hours of debugging. – Gerardo Cordero Sep 28 '22 at 22:39
  • but I add following code lines and it works `implementation "androidx.appcompat:appcompat:1.3.1" implementation "androidx.appcompat:appcompat-resources:1.3.1"` – mustafa-hsz Nov 12 '22 at 13:00
  • Works well with react native version 0.66.1 – Ali Abbas Aug 03 '23 at 05:39
15

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'
}
kangear
  • 2,493
  • 2
  • 31
  • 44
  • 2
    Works for me!!! In my case module was within a project so: ```implementation(project(':project-name')) { exclude module: 'appcompat' } ``` Thanks! – neberaa Aug 03 '21 at 09:58
6

android/app/build.gradle

paste the following code in dependencies section

implementation ("androidx.appcompat:appcompat:1.3.1") {
        version {
            strictly '1.3.1'
        }
    }
Akif
  • 69
  • 1
  • 1
  • 1
    Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Mar 31 '22 at 17:50
1

Maybe you can update react-native version to 0.68.2.

This worked for me.

Verify Gradle version: 7.0.2

-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.

-2

Update: This solution is for those who can't afford to use Appcompat 1.3.1.

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.

Rishabh876
  • 3,010
  • 2
  • 20
  • 37
  • Forking an entire library, is a bad idea. You will have to manually update it every time, won't you? – Keselme Nov 13 '22 at 09:29
  • @Keselme Agreed but old version of react native are not well supported by Facebook and in case we are on a version like 0.64.x, it's not like we are going to get any updates. And building react native from source is well documented by Facebook. Fixing this seems like the best way. If someday we move to latest React native version, we can point back to their repo. – Rishabh876 Nov 14 '22 at 09:01
  • @Keselme Just to clarify, you can continue using react native repo. Forked repo was only used to generate patched ReactAndroid-release.aar that is placed in android/app/libs. – Rishabh876 Nov 14 '22 at 09:03