简体   繁体   English

反应本机构建错误:尝试调用虚拟方法'boolean com.facebook.react.uimanager.FabricViewStateManager.hasStateWrappper()

[英]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.通过使用adb logcat并跟踪应用程序,我能够缩小导致错误的范围。

The issue stemmed from both <Input> (from react-native-elements ) and <TextInput> (from react-native ).该问题源于<Input> (来自react-native-elements )和<TextInput> (来自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.两者都会导致错误,如果我注释掉 Componenets 中的任何 Input/TextInput 元素,应用程序将正常运行。

I wasn't quite able to get it to work with @kangear 's response, but it was close.我不太能够让它与@kangear 的响应一起工作,但它很接近。 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:经过大量的挖掘和测试,我能够使用android\app\build.gradle中的以下代码行让应用程序正常工作,在dependencies项部分:

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.我尝试只使用implementation 'androidx.appcompat:appcompat:1.3.1' ,但这也不起作用。

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 )正确方法:(低于1.4

implementation "androidx.appcompat:appcompat:1.1.0"

see here: https://github.com/facebook/react-native/issues/31572见这里: 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:+第三个库内容为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 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} 1)创建新的 expo 项目expo init {yourProjectName}
No.2) Your previous project copy all your create folder and files and copy you will install dependencies command. No.2)您以前的项目复制所有创建文件夹和文件并复制您将安装依赖项命令。
No.3) You New Project Paste all folder and files and install all previous dependencies. No.3)你新建项目粘贴所有文件夹和文件并安装所有以前的依赖项。
Now you run Your Project npm start or yarn start .现在你运行你的项目npm start 或 yarn start
I hope your problem solve.我希望你的问题能解决。

Maybe you can update react-native version to 0.68.2 .也许您可以将react-native版本更新为0.68.2

This worked for me.这对我有用。

Verify Gradle version: 7.0.2验证 Gradle 版本: 7.0.2

Other solutions were not viable for me.其他解决方案对我来说不可行。 Downgrading to appcompat to 1.3.1 is not a good solution.降级到 appcompat 到 1.3.1 并不是一个好的解决方案。 And upgrading to 0.68.2 is also quite an effort.而且升级到 0.68.2 也是相当费劲的。

I instead我反而

  • forked react-native version that I was on.我使用的分叉 react-native 版本。
  • made the changes mentioned here进行了此处提到的更改
  • Re-built the ReactAndroid-release.aar by following this按照 这个重新构建 ReactAndroid-release.aar
  • place ReactAndroid-release.aar in android/app/libs将 ReactAndroid-release.aar 放在 android/app/libs

And now you can use Appcompat 1.4.x on any React native version.现在你可以在任何 React 原生版本上使用 Appcompat 1.4.x。 Tried on 0.64.3.在 0.64.3 上尝试过。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 错误:在 UIManager 中找不到“ARTShape” - React native - Error : "ARTShape" was not found in the UIManager - React native React native:动态调用方法 - React native: invoke method dynamically 错误尝试调用虚拟方法&#39;android.location.Location - error Attempt to invoke virtual method 'android.location.Location 错误登录facebook React Native - Error login facebook React Native React-Native-SVG 错误:不变违规:requireNativeComponent:在 UIManager 中找不到“RNSVGGroup” - React-Native-SVG Error: Invariant Violation: requireNativeComponent: "RNSVGGroup" was not found in the UIManager React Native iOS构建错误-检查类的render方法 - React Native iOS build Error - Check the render method of class 安装 React Native Map。 在 UIManager 中找不到 AIRMap - Installing React Native Map. AIRMap not found in UIManager 将本机UIManager.measureInWindow坐标反应为android MotionEvent坐标 - React native UIManager.measureInWindow coords to android MotionEvent coords 反应本地推送通知错误:无法在空对象上调用方法get() - react native Push Notification error: Cannot invoke method get() on null object 自定义 React Native 模块 - 无法调用方法从 react native 到 android native - Custom React Native module - not able to invoke method from react native to android native
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM