[CodePush] Unable to get the hash of the binary's bundled resources

React Native项目运行闪退:Unable to get the hash of the binary's bundled resources - "codepush.gradle" may have not been added to the build definition.这个问题之前的项目也会遇到过,也在网上查过相关资料,很意外的竟然没有相关的问题,在Google网看到有个别一样的问题但是没有人回答,也不知道怎么的项目就好了。这次又遇到了同样的问题,解决起来就没那么幸运了,搞了三天也不知道啥原因,Google、百度、Stackoverflow、Github上都查了好几遍,实在没办法才托同事帮忙找原因,同事搞到了凌晨两点才找到原因。


"Could not get BatchedBridge, make sure your bundle is packaged correctly"遇到这问题的人倒是很多的,而这个也是在手机上报红的,说明这个项目运行起来了,而我的项目没运行起来就闪退了。这个问题网上给的答案是:在终端cd 到项目的跟目录,然后运行

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

问题就解决了,不知道是不是ReactNative版本升级的问题,这样虽然能运行起来了,但是打包的时候打不了包。仔细看这句就是把index.android.bundle这个文件放到项目的assets文件夹下面,自动把资源文件(即本地图片)放到res下,这种方法感觉不怎么靠谱


所以当项目报红Could not get BatchedBridge, make sure your bundle is packaged correctly的时候最好不要运行

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

报这个错有两点:

1、检查WI-FI是否跟电脑一样的

2、没有运行react-native start


再来说说解决我项目闪退的问题。Unable to get the hash of the binary's bundled resources - "codepush.gradle" may have not been added to the build definition.

这句大概意思就是找不到这个bundled resources 文件,codepush.gradle可能没有添加到build里面,release情况下能正常运行,Debug模式下运行不起来,其实是在Debug模式被禁了,


之所以被禁是因为这个在MainApplication里面配置CodePush的时候BuildConfig引用错了

new CodePush("", getApplicationContext(), BuildConfig.DEBUG)


它引用的是com.facebook.react这个包下的BuildConfig,而这个的值是false,所以Debug模式下运行不起来,

解决办法就是把这个引用importcom.facebook.react.BuildConfig;删掉了


删掉之后就会使用项目自带的BuildConfig,而项目自带的值是true


问题就这样解决了。






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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值