From bce345b65dc18cf598a8e0606f1064bf0bcce419 Mon Sep 17 00:00:00 2001 From: tdzl2003 Date: Tue, 5 Apr 2016 23:11:28 +0800 Subject: [PATCH] =?UTF-8?q?bugfix:=20=E4=BB=8E=E5=AE=89=E8=A3=85=E5=8C=85?= =?UTF-8?q?=E9=A6=96=E6=AC=A1=E6=9B=B4=E6=96=B0=E5=90=8E=E5=8D=B3=E5=9B=9E?= =?UTF-8?q?=E6=BB=9A=E5=A4=84=E7=90=86=E6=9C=89=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/UpdateContext.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/android/src/main/java/cn/reactnative/modules/update/UpdateContext.java b/android/src/main/java/cn/reactnative/modules/update/UpdateContext.java index 3f47682..b7c54b7 100644 --- a/android/src/main/java/cn/reactnative/modules/update/UpdateContext.java +++ b/android/src/main/java/cn/reactnative/modules/update/UpdateContext.java @@ -174,16 +174,20 @@ public class UpdateContext { currentVersion = this.rollBack(); } } + if (currentVersion == null) { + return defaultAssetsUrl; + } return (new File(rootDir, currentVersion+"/index.bundlejs").toString()); } private String rollBack() { String lastVersion = sp.getString("lastVersion", null); - if (lastVersion == null) { - throw new Error("This should never happen"); - } SharedPreferences.Editor editor = sp.edit(); - editor.putString("currentVersion", lastVersion); + if (lastVersion == null) { + editor.remove("currentVersion"); + } else { + editor.putString("currentVersion", lastVersion); + } editor.putBoolean("firstTimeOk", true); editor.putBoolean("firstTime", false); editor.putBoolean("rolledBack", true);