1
0
Code Issues Pull Requests Packages Projects Releases Wiki Activity GitHub Gitee

解决安卓更新重启问题

This commit is contained in:
tdzl2003 2017-05-04 20:23:16 +08:00
parent dd693f4cee
commit 26708dc5bd
2 changed files with 7 additions and 7 deletions

View File

@ -124,15 +124,15 @@ public class UpdateModule extends ReactContextBaseJavaModule{
Application application = activity.getApplication();
ReactInstanceManager instanceManager = ((ReactApplication) application).getReactNativeHost().getReactInstanceManager();
if (instanceManager.getClass().getSimpleName().equals("XReactInstanceManagerImpl")) {
JSBundleLoader loader = JSBundleLoader.createFileLoader(UpdateContext.getBundleUrl(application));
Field jsBundleField = instanceManager.getClass().getDeclaredField("mBundleLoader");
jsBundleField.setAccessible(true);
jsBundleField.set(instanceManager, loader);
} else {
try {
Field jsBundleField = instanceManager.getClass().getDeclaredField("mJSBundleFile");
jsBundleField.setAccessible(true);
jsBundleField.set(instanceManager, UpdateContext.getBundleUrl(application));
} catch (Throwable err) {
JSBundleLoader loader = JSBundleLoader.createFileLoader(UpdateContext.getBundleUrl(application));
Field loadField = instanceManager.getClass().getDeclaredField("mBundleLoader");
loadField.setAccessible(true);
loadField.set(instanceManager, loader);
}
final Method recreateMethod = instanceManager.getClass().getMethod("recreateReactContextInBackground");

View File

@ -1,6 +1,6 @@
{
"name": "react-native-update",
"version": "4.0.0",
"version": "4.0.2",
"description": "react-native hot update",
"main": "lib/index.js",
"scripts": {