Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

正确使用code-push热更新中的第五条 #91

Closed
obstrux opened this issue Sep 11, 2017 · 5 comments
Closed

正确使用code-push热更新中的第五条 #91

obstrux opened this issue Sep 11, 2017 · 5 comments

Comments

@obstrux
Copy link

obstrux commented Sep 11, 2017

每次发版本,都要部署一次codepush,为什么第一次部署的codepush也会被下载

@lisong
Copy link
Owner

lisong commented Sep 15, 2017

iOS应该不会这样,andriod确实有bug microsoft/react-native-code-push#1000

@lisong lisong closed this as completed Mar 18, 2018
@openUmbrella
Copy link
Contributor

在我的项目中, iOS项目也会出现这个问题。通过抓包如下:
image
我认为是本地的原始包的hash值和服务器的更新包的hash值不一样,才会触发更新。

@lisong
Copy link
Owner

lisong commented May 15, 2019

是的,andriod首次按照无法拿到资源文件,andriod将资源文件也压缩到apk包里面,需要通过反编译获取,所以andriod首次安装无法增量更新

@openUmbrella
Copy link
Contributor

@lisong 你好,可是我的是iOS项目啊,我确保代码没有改动,同时打包的命令参数也是一致的。但是最终的hash值却不一样。我不知道问题出在哪里了。

@openUmbrella
Copy link
Contributor

经过一番排查,上面提到的问题的原因是因为RN预先设置了在运行项目过程中,先会执行react-native-xcode.sh脚本,而这个脚本的主要目的是打RN包,然后保存到App包内,也就是执行 react-native bundle命令,其中的dev参数的值是根据iOS模式下决定的,debug模式下是true,其他的是false。而我在运行项目时,是在debug模式下使用真机来跑的,app里面的main.jsbundle其实是react-native-xcode.sh脚本新打的dev为true的main.jsbundle包(如果在运行app之前手动将打好的包引入,会被脚本新打的到替换掉)。而我们上传到服务器的main.jsbundle包dev为false。由于打包时的dev参数的值不同,导致了main.jsbundle包不同,再进而导致了两个main.jsbundle的hash值不同,最终计算的hash也就不同了。
其实如果是在生产环境的话,就不会出现这个问题了。
希望大家能够借鉴,别再掉坑里了

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants