[英]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
./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'
}
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我反而
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.