原生Android应用集成react-native混编

记载的是已有android工程,要集成react-native的过程,所记录的问题在stackoverflow都可以找到解决办法的

1.引入react-native 参考:

https://blog.csdn.net/mhhyoucom/article/details/83619011

2.运行时可能报错:Activity needs to be set if initial lifecycle state is resumed

解决参考:https://stackoverflow.com/questions/56946788/activity-needs-to-be-set-if-initial-lifecycle-state-is-resumed

3.继续运行报错:java.lang.UnsatisfiedLinkError: couldn't find DSO to load: libfbjni.so result: 0

解决参考:https://github.com/facebook/react-native/issues/25986

4.继续运行,可能已经跑起来了,界面出现红色报错

Could not connect to development server

Unable to load script.Make sure you're either running a metro server( run 'react-native s...

参考:https://blog.csdn.net/u014763476/article/details/53836432

Unable to load script from assets 'index.android.bundle'. Make sure your bundle is packaged correctly or you're running a packager server

参考:https://stackoverflow.com/questions/44795384/unable-to-load-script-from-assets-index-android-bundle-make-sure-your-bundle

5.Invalid regular expression: /(node_modules[\\\]react[\\\]dist[\\\].*|website\\node_modules\\.*|heapCapture\\bundle\.js)$/: Unterminated character class

找到blacklist.js文件 修改为:/node_modules[\/\\]react[\/\\]dist[\/\\].*/......

6.AndroidRuntime: java.lang.NoSuchMethodError: No virtual method toString(Z)Ljava/lang/String; in class Lokhttp3/Cookie; or its super classes (declaration of 'okhttp3.Cookie' appears in /data/app/com.piglet-VoaKTU4zctXOlMHherGcyg==/base.apk!classes2.dex)

okhttp版本不一致导致,需要修改okhttp版本。或者修改你工程的版本,或者修改react-native的okhttp版本

修改react-native的okhttp的版本参考:https://blog.csdn.net/abccjf/article/details/56011551

7.纯RN应用调用android原生方法按照官方文档来就行,而混编的调用则有个坑 如遇到  ... of null:

参考 https://www.jianshu.com/p/54172c54b95f

这几个问题解决完,就能运行起来了

我这里要调研的是rn热更新,第一步完成了,继续下一步热更新了

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值