React-Native踩过的那些坑

来源:互联网 发布:ubuntu on windows 10 编辑:程序博客网 时间:2024/06/15 07:59
  • 问题1:undefined is not an object (evaluating ‘ReactInternals.ReactCurrentOwner’)

出现这个错误让我搞了半天,刚开始以为是this指针绑定问题,最后发现不是。

解决方案:

先在项目根目录执行

npm install

然后再

npm start
  • 问题2:No dimension set for key window

错误2

解决方案:

关闭远程,清空项目,然后重新运行app。Try closing terminal, deleting ios/build and run again. I had the same issue but now its working.

  • 问题3:打包好的ReactNative运行在自己X64CPU的手机上,打开RN页面直接闪退

错误:

java.lang.UnsatisfiedLinkError: dlopen failed: "xxx/libgnustl_shared.so" is 32-bit instead of 64-bit

解决方案:

1、在项目的根目录的 gradle.properties里面添加一行代码

android.useDeprecatedNdk=true.

2、在project的root目录下的build.gradle中添加如下代码。

defaultConfig {     ···    ndk{         abiFilters "armeabi-v7a","x86"     }     packagingOptions {         exclude "lib/arm64-v8a/librealm-jni.so"     } }
  • 问题4:Could not get BatchedBridge, make sure your bundle is packaged correctly

解决方案:

首先确认手机的网和电脑的网在不在同一网段。然后需要查看React Packger是否Loading Js 文件。设置Dev Setting的ip地址以及网段。

原创粉丝点击