Skip to content

Commit ebc9b97

Browse files
committed
fix proguard
1 parent 40742e1 commit ebc9b97

File tree

6 files changed

+56
-16
lines changed

6 files changed

+56
-16
lines changed

Example/testHotUpdate/bun.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"react-native-paper": "^5.14.5",
1313
"react-native-safe-area-context": "^5.4.1",
1414
"react-native-svg": "^15.12.0",
15-
"react-native-update": "^10.28.11",
15+
"react-native-update": "^10.29.0",
1616
"react-native-vector-icons": "^10.2.0",
1717
},
1818
"devDependencies": {
@@ -1420,7 +1420,7 @@
14201420

14211421
"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=="],
14221422

1423-
"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=="],
1423+
"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=="],
14241424

14251425
"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=="],
14261426

Example/testHotUpdate/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"react-native-paper": "^5.14.5",
2323
"react-native-safe-area-context": "^5.4.1",
2424
"react-native-svg": "^15.12.0",
25-
"react-native-update": "^10.28.11",
25+
"react-native-update": "^10.29.0",
2626
"react-native-vector-icons": "^10.2.0"
2727
},
2828
"devDependencies": {
@@ -52,4 +52,4 @@
5252
"detox",
5353
"dtrace-provider"
5454
]
55-
}
55+
}

android/proguard.pro

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,37 @@
1+
# Keep our update module classes
12
-keepnames class cn.reactnative.modules.update.DownloadTask { *; }
23
-keepnames class cn.reactnative.modules.update.UpdateModuleImpl { *; }
3-
-keepnames class com.facebook.react.ReactInstanceManager { *; }
4+
-keepnames class cn.reactnative.modules.update.** { *; }
5+
6+
# Keep React Native classes
7+
-keepnames class com.facebook.react.ReactInstanceManager { *; }
8+
-keepnames class com.facebook.react.** { *; }
9+
-keepnames class com.facebook.react.bridge.** { *; }
10+
-keepnames class com.facebook.react.devsupport.** { *; }
11+
12+
# Keep fields used in reflection
13+
-keepclassmembers class com.facebook.react.ReactInstanceManager {
14+
private JSBundleLoader mBundleLoader;
15+
private String mJSBundleFile;
16+
}
17+
18+
-keepclassmembers class com.facebook.react.ReactDelegate {
19+
private ReactHost mReactHost;
20+
}
21+
22+
-keepclassmembers class com.facebook.react.ReactHost {
23+
private boolean mUseDevSupport;
24+
private ReactHostDelegate mReactHostDelegate;
25+
}
26+
27+
# Keep Expo related classes
28+
-keepnames class expo.modules.ExpoReactHostFactory$ExpoReactHostDelegate { *; }
29+
30+
# Keep methods used in reflection
31+
-keepclassmembers class com.facebook.react.ReactActivity {
32+
public ReactDelegate getReactDelegate();
33+
}
34+
35+
-keepclassmembers class com.facebook.react.ReactHost {
36+
public void reload(java.lang.String);
37+
}

android/src/main/java/cn/reactnative/modules/update/UpdateContext.java

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -169,17 +169,19 @@ public String rolledBackVersion() {
169169
}
170170

171171
public void markSuccess() {
172-
SharedPreferences.Editor editor = sp.edit();
173-
editor.putBoolean("firstTimeOk", true);
174-
String lastVersion = sp.getString("lastVersion", null);
175-
String curVersion = sp.getString("currentVersion", null);
176-
if (lastVersion != null && !lastVersion.equals(curVersion)) {
177-
editor.remove("lastVersion");
178-
editor.remove("hash_" + lastVersion);
179-
}
180-
editor.apply();
172+
if (!BuildConfig.DEBUG) {
173+
SharedPreferences.Editor editor = sp.edit();
174+
editor.putBoolean("firstTimeOk", true);
175+
String lastVersion = sp.getString("lastVersion", null);
176+
String curVersion = sp.getString("currentVersion", null);
177+
if (lastVersion != null && !lastVersion.equals(curVersion)) {
178+
editor.remove("lastVersion");
179+
editor.remove("hash_" + lastVersion);
180+
}
181+
editor.apply();
181182

182-
this.cleanUp();
183+
this.cleanUp();
184+
}
183185
}
184186

185187
public void clearFirstTime() {

android/src/main/java/cn/reactnative/modules/update/UpdateModuleImpl.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,10 @@ public void run() {
147147
reactHostField.setAccessible(true);
148148
Object reactHost = reactHostField.get(reactDelegate);
149149

150+
Field devSupport = reactHost.getClass().getDeclaredField("mUseDevSupport");
151+
devSupport.setAccessible(true);
152+
devSupport.set(reactHost, false);
153+
150154
// Access the mReactHostDelegate field
151155
Field reactHostDelegateField = reactHost.getClass().getDeclaredField("mReactHostDelegate");
152156
reactHostDelegateField.setAccessible(true);

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-update",
3-
"version": "10.29.0",
3+
"version": "10.29.1",
44
"description": "react-native hot update",
55
"main": "src/index",
66
"scripts": {

0 commit comments

Comments
 (0)