diff --git a/android/app/src/main/java/com/microsoft/codepush/react/CodePushNativeModule.java b/android/app/src/main/java/com/microsoft/codepush/react/CodePushNativeModule.java index 0ae0b0be0..e8ccd9fdb 100644 --- a/android/app/src/main/java/com/microsoft/codepush/react/CodePushNativeModule.java +++ b/android/app/src/main/java/com/microsoft/codepush/react/CodePushNativeModule.java @@ -105,10 +105,12 @@ private void setJSBundle(ReactInstanceManager instanceManager, String latestJSBu 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 @@ private void setJSBundle(ReactInstanceManager instanceManager, String latestJSBu // 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");