记载的是已有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
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
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热更新,第一步完成了,继续下一步热更新了