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

Commit b8bd4a0

Browse files
Maxsergey-akhalkov
authored andcommitted
Fixed issue with [Android] restartApp() throwing exception w/ release build (#861)
* Fixed issue with error on parsing plist path See #534 (comment) for details * Fixed issue with [Android] restartApp() throwing exception w/ release build #847 * Changed return value to null for getUpdateMetadata instead of empty string In accordance with docs and #862 * Code refactoring: moved variable assignment out of loop
1 parent 3761d9e commit b8bd4a0

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,12 @@ private void setJSBundle(ReactInstanceManager instanceManager, String latestJSBu
105105
Field bundleLoaderField = instanceManager.getClass().getDeclaredField("mBundleLoader");
106106
Class<?> jsBundleLoaderClass = Class.forName("com.facebook.react.cxxbridge.JSBundleLoader");
107107
Method createFileLoaderMethod = null;
108+
String createFileLoaderMethodName = latestJSBundleFile.toLowerCase().startsWith("assets://")
109+
? "createAssetLoader" : "createFileLoader";
108110

109111
Method[] methods = jsBundleLoaderClass.getDeclaredMethods();
110-
for (Method method : methods) {
111-
if (method.getName().equals("createFileLoader")) {
112+
for (Method method : methods) {
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)