Skip to content
This repository was archived by the owner on May 20, 2025. It is now read-only.

Commit 1034c6c

Browse files
author
max-mironov
committed
Fixed issue with [Android] restartApp() throwing exception w/ release build
#847
1 parent dec9398 commit 1034c6c

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

android/app/src/main/java/com/microsoft/codepush/react/CodePushNativeModule.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,9 @@ private void setJSBundle(ReactInstanceManager instanceManager, String latestJSBu
108108

109109
Method[] methods = jsBundleLoaderClass.getDeclaredMethods();
110110
for (Method method : methods) {
111-
if (method.getName().equals("createFileLoader")) {
111+
String createFileLoaderMethodName = latestJSBundleFile.toLowerCase().startsWith("assets://")
112+
? "createAssetLoader" : "createFileLoader";
113+
if (method.getName().equals(createFileLoaderMethodName)) {
112114
createFileLoaderMethod = method;
113115
break;
114116
}
@@ -125,7 +127,7 @@ private void setJSBundle(ReactInstanceManager instanceManager, String latestJSBu
125127
// RN >= v0.34
126128
latestJSBundleLoader = createFileLoaderMethod.invoke(jsBundleLoaderClass, latestJSBundleFile);
127129
} else if (numParameters == 2) {
128-
// RN >= v0.31 && RN < v0.34
130+
// RN >= v0.31 && RN < v0.34 or AssetLoader instance
129131
latestJSBundleLoader = createFileLoaderMethod.invoke(jsBundleLoaderClass, getReactApplicationContext(), latestJSBundleFile);
130132
} else {
131133
throw new NoSuchMethodException("Could not find a recognized 'createFileLoader' method");

0 commit comments

Comments
 (0)