ReactNative常见错误

334 阅读1分钟

1. java.util.concurrent.ExecutionException:java.lang.RuntimeException:ReferenceError:Can't find variable:__fbBatchedBride或者Couldn‘t get the native call queue:bridge configuration isn't available

解决办法:adb reverse tcp:8081 tcp:8081

2.Android模拟器调不出Menu菜单

按两下R键,或者按crtl+M

3.React Native红屏500错误解决办法

关掉node后台进程,用npm start -- --reset-cache命令重新启动packager服务

4.TypeError: Cannot read property 'bindings' of null

When upgrading to 0.56, make sure to bump your babel-preset-react-native package.json dependency to ^5.0.1 or newer.

babel-preset-react-native更新到最新,例如:

{
    "babel-jest": "23.4.0",
    "babel-preset-react-native": "5.0.2",
    "jest": "23.4.1",
    "react-test-renderer": "16.4.1"
}

5.看不到日志

1)Android下

#react-native log-android

2)Ios下

#react-native log-ios

6.androidx错误

直接删除androidx相关引用,用其他代替。比如 import androidx.annotation.Nullable替换为import android.support.annotation.Nullable

7.引用了太多原生项目,编译错误

What went wrong: Execution failed for task ':app:processDebugResources'.

Failed to process resources, see aapt output above for details

有可能是版本不一致,比如库文件compileSdkVersion=28,而主项目appcompileSdkVersion=27。将主项目的版本提高,至少比引用的库文件版本要更高