@@ -53,6 +53,8 @@ public class CodePush {
53
53
private final String CODE_PUSH_TAG = "CodePush" ;
54
54
private final String DOWNLOAD_PROGRESS_EVENT_NAME = "CodePushDownloadProgress" ;
55
55
private final String RESOURCES_BUNDLE = "resources.arsc" ;
56
+ // This needs to be kept in sync with https://github.com/facebook/react-native/blob/master/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevSupportManager.java#L78
57
+ private final String REACT_DEV_BUNDLE_CACHE_FILE_NAME = "ReactNativeDevBundle.js" ;
56
58
57
59
private CodePushPackage codePushPackage ;
58
60
private CodePushReactPackage codePushReactPackage ;
@@ -236,6 +238,8 @@ private void initializeUpdateAfterRestart() {
236
238
// Therefore, deduce that it is a broken update and rollback.
237
239
rollbackPackage ();
238
240
} else {
241
+ // Clear the React dev bundle cache so that new updates can be loaded.
242
+ clearReactDevBundleCache ();
239
243
// Mark that we tried to initialize the new update, so that if it crashes,
240
244
// we will know that we need to rollback when the app next starts.
241
245
savePendingUpdate (pendingUpdate .getString (PENDING_UPDATE_HASH_KEY ),
@@ -248,20 +252,18 @@ private void initializeUpdateAfterRestart() {
248
252
}
249
253
}
250
254
255
+ private void clearReactDevBundleCache () {
256
+ File cachedDevBundle = new File (this .applicationContext .getFilesDir (), REACT_DEV_BUNDLE_CACHE_FILE_NAME );
257
+ if (cachedDevBundle .exists ()) {
258
+ cachedDevBundle .delete ();
259
+ }
260
+ }
261
+
251
262
private class CodePushNativeModule extends ReactContextBaseJavaModule {
252
263
253
264
private LifecycleEventListener lifecycleEventListener = null ;
254
- private static final String JS_BUNDLE_FILE_NAME = "ReactNativeDevBundle.js" ;
255
-
256
- private void clearReactDevBundleCache () {
257
- File cachedDevBundle = new File (getReactApplicationContext ().getFilesDir (), JS_BUNDLE_FILE_NAME );
258
- if (cachedDevBundle .exists ()) {
259
- cachedDevBundle .delete ();
260
- }
261
- }
262
265
263
266
private void loadBundle () {
264
- clearReactDevBundleCache ();
265
267
Intent intent = mainActivity .getIntent ();
266
268
mainActivity .finish ();
267
269
mainActivity .startActivity (intent );
0 commit comments