mirror of
https://github.com/zhigang1992/react-native-code-push.git
synced 2026-06-17 03:59:19 +08:00
Fixed issue with [Android] restartApp() throwing exception w/ release build (#861)
* Fixed issue with error on parsing plist path See https://github.com/Microsoft/react-native-code-push/issues/534#issuecomment-302069326 for details * Fixed issue with [Android] restartApp() throwing exception w/ release build https://github.com/Microsoft/react-native-code-push/issues/847 * Changed return value to null for getUpdateMetadata instead of empty string In accordance with docs and https://github.com/Microsoft/react-native-code-push/issues/862 * Code refactoring: moved variable assignment out of loop
This commit is contained in:
@@ -105,10 +105,12 @@ public class CodePushNativeModule extends ReactContextBaseJavaModule {
|
||||
Field bundleLoaderField = instanceManager.getClass().getDeclaredField("mBundleLoader");
|
||||
Class<?> jsBundleLoaderClass = Class.forName("com.facebook.react.cxxbridge.JSBundleLoader");
|
||||
Method createFileLoaderMethod = null;
|
||||
String createFileLoaderMethodName = latestJSBundleFile.toLowerCase().startsWith("assets://")
|
||||
? "createAssetLoader" : "createFileLoader";
|
||||
|
||||
Method[] methods = jsBundleLoaderClass.getDeclaredMethods();
|
||||
for (Method method : methods) {
|
||||
if (method.getName().equals("createFileLoader")) {
|
||||
for (Method method : methods) {
|
||||
if (method.getName().equals(createFileLoaderMethodName)) {
|
||||
createFileLoaderMethod = method;
|
||||
break;
|
||||
}
|
||||
@@ -125,7 +127,7 @@ public class CodePushNativeModule extends ReactContextBaseJavaModule {
|
||||
// RN >= v0.34
|
||||
latestJSBundleLoader = createFileLoaderMethod.invoke(jsBundleLoaderClass, latestJSBundleFile);
|
||||
} else if (numParameters == 2) {
|
||||
// RN >= v0.31 && RN < v0.34
|
||||
// RN >= v0.31 && RN < v0.34 or AssetLoader instance
|
||||
latestJSBundleLoader = createFileLoaderMethod.invoke(jsBundleLoaderClass, getReactApplicationContext(), latestJSBundleFile);
|
||||
} else {
|
||||
throw new NoSuchMethodException("Could not find a recognized 'createFileLoader' method");
|
||||
|
||||
Reference in New Issue
Block a user