React Native错误记录

我们在开发RN过程中难免会遇到一些错误,下面是本人遇到过的一些,记录下来,方便大家尽快解决问题:
1.The development server returned response error code:404http://10.0.2.2:8081/index.android.bundle?platform=android&dev=true&hot=false&minify=false
检查手机是否联网
打开调试模式,Dev Setting,点击Debug server host & port for device,添加localhost:8081

  1. unable to load script from assets ‘index.android bundle’ ,make sure your bundle is packaged correctly or youu’re runing a packager server

第一步:在Android/app/src/main目录下创建一个空的assets文件夹,
第二步:进入项目根目录执行下面代码:
react-native bundle –platform android –dev false –entry-file index.android.js –bundle-output android/app/src/main/assets/index.android.bundle –assets-dest android/app/src/main/res/
注:
index.android.bundle是用来调用原生控件的js脚本,每次当改变了 index.android.js,都需要使用上面的代码片段,来及时的更新index.android.bundle,然后打包才可以把新的index.android.js应用上,所以当没有index.android.bundle文件时,React-Native 项目是无法运行的。 新版本目录下没有index.android.js和index.ios.js,所以会出现Cannot find entry file index.android.js 使用index.js替换即可

3.
Error:Execution failed for task ‘:app:transformNativeLibsWithStripDebugSymbolForDebug’.

A problem occurred starting process ‘command ‘/Users/sunhangxing/Library/Android/sdk/ndk-bundle/toolchains/mips64el-linux-android-4.9/prebuilt/darwin-x86_64/bin/mips64el-linux-android-strip”
新版NDK更改了文件目录导致找不到,在Androidstudio中关掉ndk的路径即可

4.Packager can’t listen on port 8081
Most likely another process is already using this port
已经起了一个服务,不需要重新启动或者该端口被占用

5.RN项目中调用view的layout方法无效或者页面不刷新问题
RN重写了Android的onLayout等方法,导致原生的直接调用无效,需要重写该方法

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值