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:
Max
2017-06-01 14:10:33 +03:00
committed by Sergey Akhalkov
parent 3761d9ece0
commit b8bd4a021c

View File

@@ -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");