1. 集成 RN 之后出现内存泄漏
使用 RN ReactRootView 之后记得 unmount
@Override
public void onDestroyView() {
super.onDestroyView();
if(mReactRootView != null){
mReactRootView.unmountReactApplication();
}
}
这里我是用 RN 生成一个 View 添加到 ViewGroup 中,所以会使用到 ReactRootView ,一般 RN 集成会直接继承 ReactActivity ,所以一般不需要自己调用。
2.
Error: Cannot find module '/Users/dadadadadaying/Documents/Android/NewPregnotice/pregnotice-android/app/pregnotice-rn/node_modules"/react-native-code-push/scripts/recordFilesBeforeBundleCommand.js'
> Task :app:recordFilesBeforeBundleCommandTencentDebug
module.js:538
throw err;
^
Error: Cannot find module '/Users/dadadadadaying/Documents/Android/NewPregnotice/pregnotice-android/app/pregnotice-rn/node_modules"/react-native-code-push/scripts/recordFilesBeforeBundleCommand.js'
at Function.Module._resolveFilename (module.js:536:15)
at Function.Module._load (module.js:466:25)
at Function.Module.runMain (module.js:676:10)
at startup (bootstrap_node.js:187:16)
at bootstrap_node.js:608:3
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:recordFilesBeforeBundleCommandTencentDebug'.
> Process 'command 'node'' finished with non-zero exit value 1
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
* Get more help at https://help.gradle.org
BUILD FAILED in 24s
企业微信截图_d8748bd9-c3af-48cc-880c-d25f494ba44c.png这里是 codepush 里的问题,看 codepush 中的 codepush.gradle
nodeModulesPath 是在 gradle.properties 中设置的
nodeModulesPath="../../pregnotice-rn/node_modules"
这里是不能加引号的,加引号会导致路径拼接错误,即上面所说的错误。之前windows 上也是这种写法,但是从来没有出过错误。换回 mac 之后就出现了这种错误,坑爹,花了我大半天时间查找这个错误。各种换ide.... 正确的代码如下
nodeModulesPath= ../../pregnotice-rn/node_modules
网友评论