From 26708dc5bd2912f0e832b2a35c47ddf76846d55a Mon Sep 17 00:00:00 2001 From: tdzl2003 Date: Thu, 4 May 2017 20:23:16 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E5=AE=89=E5=8D=93=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E9=87=8D=E5=90=AF=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cn/reactnative/modules/update/UpdateModule.java | 12 ++++++------ package.json | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/android/src/main/java/cn/reactnative/modules/update/UpdateModule.java b/android/src/main/java/cn/reactnative/modules/update/UpdateModule.java index b07fd6f..02befd0 100644 --- a/android/src/main/java/cn/reactnative/modules/update/UpdateModule.java +++ b/android/src/main/java/cn/reactnative/modules/update/UpdateModule.java @@ -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"); diff --git a/package.json b/package.json index 23a3591..ef253b4 100644 --- a/package.json +++ b/package.json @@ -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": {