diff --git a/Example/testHotUpdate/bun.lock b/Example/testHotUpdate/bun.lock index 1d6050b..e968093 100644 --- a/Example/testHotUpdate/bun.lock +++ b/Example/testHotUpdate/bun.lock @@ -12,7 +12,7 @@ "react-native-paper": "^5.14.5", "react-native-safe-area-context": "^5.4.1", "react-native-svg": "^15.12.0", - "react-native-update": "^10.28.11", + "react-native-update": "^10.29.0", "react-native-vector-icons": "^10.2.0", }, "devDependencies": { @@ -1420,7 +1420,7 @@ "react-native-svg": ["react-native-svg@15.12.0", "", { "dependencies": { "css-select": "^5.1.0", "css-tree": "^1.1.3", "warn-once": "0.1.1" }, "peerDependencies": { "react": "*", "react-native": "*" } }, "sha512-iE25PxIJ6V0C6krReLquVw6R0QTsRTmEQc4K2Co3P6zsimU/jltcDBKYDy1h/5j9S/fqmMeXnpM+9LEWKJKI6A=="], - "react-native-update": ["react-native-update@10.28.11", "", { "dependencies": { "nanoid": "^3.3.3", "react-native-url-polyfill": "^2.0.0" }, "peerDependencies": { "react": ">=16.8.0", "react-native": ">=0.59.0" } }, "sha512-afoaUsUFwIKj4lETWm5ilfMcWkbcTId0HJ9PaL9G0sPUBNokT0TdLPPezVglYqVWFTe8I+KAS0yD7hLG9F9StA=="], + "react-native-update": ["react-native-update@10.29.0", "", { "dependencies": { "nanoid": "^3.3.3", "react-native-url-polyfill": "^2.0.0" }, "peerDependencies": { "react": ">=16.8.0", "react-native": ">=0.59.0" } }, "sha512-TFGwJxI62OHPJimxMnI8PDvUBhZio1alsgIvXHYh1oYAZYYejkUvwl+Ojdbm58IKoZzxAaT7RvD1qGdvlg/oKg=="], "react-native-url-polyfill": ["react-native-url-polyfill@2.0.0", "", { "dependencies": { "whatwg-url-without-unicode": "8.0.0-3" }, "peerDependencies": { "react-native": "*" } }, "sha512-My330Do7/DvKnEvwQc0WdcBnFPploYKp9CYlefDXzIdEaA+PAhDYllkvGeEroEzvc4Kzzj2O4yVdz8v6fjRvhA=="], diff --git a/Example/testHotUpdate/package.json b/Example/testHotUpdate/package.json index 23fdbb5..508ebff 100644 --- a/Example/testHotUpdate/package.json +++ b/Example/testHotUpdate/package.json @@ -22,7 +22,7 @@ "react-native-paper": "^5.14.5", "react-native-safe-area-context": "^5.4.1", "react-native-svg": "^15.12.0", - "react-native-update": "^10.28.11", + "react-native-update": "^10.29.0", "react-native-vector-icons": "^10.2.0" }, "devDependencies": { @@ -52,4 +52,4 @@ "detox", "dtrace-provider" ] -} \ No newline at end of file +} diff --git a/android/proguard.pro b/android/proguard.pro index cb61f06..4b87fce 100644 --- a/android/proguard.pro +++ b/android/proguard.pro @@ -1,3 +1,37 @@ +# Keep our update module classes -keepnames class cn.reactnative.modules.update.DownloadTask { *; } -keepnames class cn.reactnative.modules.update.UpdateModuleImpl { *; } --keepnames class com.facebook.react.ReactInstanceManager { *; } \ No newline at end of file +-keepnames class cn.reactnative.modules.update.** { *; } + +# Keep React Native classes +-keepnames class com.facebook.react.ReactInstanceManager { *; } +-keepnames class com.facebook.react.** { *; } +-keepnames class com.facebook.react.bridge.** { *; } +-keepnames class com.facebook.react.devsupport.** { *; } + +# Keep fields used in reflection +-keepclassmembers class com.facebook.react.ReactInstanceManager { + private JSBundleLoader mBundleLoader; + private String mJSBundleFile; +} + +-keepclassmembers class com.facebook.react.ReactDelegate { + private ReactHost mReactHost; +} + +-keepclassmembers class com.facebook.react.ReactHost { + private boolean mUseDevSupport; + private ReactHostDelegate mReactHostDelegate; +} + +# Keep Expo related classes +-keepnames class expo.modules.ExpoReactHostFactory$ExpoReactHostDelegate { *; } + +# Keep methods used in reflection +-keepclassmembers class com.facebook.react.ReactActivity { + public ReactDelegate getReactDelegate(); +} + +-keepclassmembers class com.facebook.react.ReactHost { + public void reload(java.lang.String); +} \ No newline at end of file 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 36fa9fb..d1a95bf 100644 --- a/android/src/main/java/cn/reactnative/modules/update/UpdateContext.java +++ b/android/src/main/java/cn/reactnative/modules/update/UpdateContext.java @@ -169,17 +169,19 @@ public class UpdateContext { } public void markSuccess() { - SharedPreferences.Editor editor = sp.edit(); - editor.putBoolean("firstTimeOk", true); - String lastVersion = sp.getString("lastVersion", null); - String curVersion = sp.getString("currentVersion", null); - if (lastVersion != null && !lastVersion.equals(curVersion)) { - editor.remove("lastVersion"); - editor.remove("hash_" + lastVersion); - } - editor.apply(); + if (!BuildConfig.DEBUG) { + SharedPreferences.Editor editor = sp.edit(); + editor.putBoolean("firstTimeOk", true); + String lastVersion = sp.getString("lastVersion", null); + String curVersion = sp.getString("currentVersion", null); + if (lastVersion != null && !lastVersion.equals(curVersion)) { + editor.remove("lastVersion"); + editor.remove("hash_" + lastVersion); + } + editor.apply(); - this.cleanUp(); + this.cleanUp(); + } } public void clearFirstTime() { diff --git a/android/src/main/java/cn/reactnative/modules/update/UpdateModuleImpl.java b/android/src/main/java/cn/reactnative/modules/update/UpdateModuleImpl.java index 19518eb..349191f 100644 --- a/android/src/main/java/cn/reactnative/modules/update/UpdateModuleImpl.java +++ b/android/src/main/java/cn/reactnative/modules/update/UpdateModuleImpl.java @@ -147,6 +147,10 @@ public class UpdateModuleImpl { reactHostField.setAccessible(true); Object reactHost = reactHostField.get(reactDelegate); + Field devSupport = reactHost.getClass().getDeclaredField("mUseDevSupport"); + devSupport.setAccessible(true); + devSupport.set(reactHost, false); + // Access the mReactHostDelegate field Field reactHostDelegateField = reactHost.getClass().getDeclaredField("mReactHostDelegate"); reactHostDelegateField.setAccessible(true); diff --git a/package.json b/package.json index 119ce9e..f3550f5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-native-update", - "version": "10.29.0", + "version": "10.29.1", "description": "react-native hot update", "main": "src/index", "scripts": {