1

We are attempting to implement CodePush from Microsoft App Center. We have managed to get to the point where the application downloads the package, and unpacks it. However, it always ends with the response

Update is invalid - A JS bundle file named "null" could not be found within the downloaded contents. Please check that you are releasing your CodePush updates using the exact same JS bundle file name that was shipped with your app's binary.

  • react@16.2.0
  • react-native@0.53.3
  • react-native-code-push@5.3.2

We've made the changes to the MainApplication.java

private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {

  @NonNull
    @Override
    protected String getJSBundleFile() {
    return CodePush.getJSBundleFile();
    }

and

protected List<ReactPackage> getPackages() {
   return Arrays.<ReactPackage>asList(
   // Add additional packages you require here
   // No need to add RnnPackage and MainReactPackage
   new ActionSheetPackage(),
   new PickerPackage(),
   new ReactNativeOneSignalPackage(),
   new CodePush(getResources().getString(R.string.reactNativeCodePush_androidDeploymentKey), getApplicationContext(), BuildConfig.DEBUG),
   new CalendarEventsPackage()
 );
}

In the app code, we call

 Navigation.registerComponent(ScreenNames.Landing.id, () => CodePush(codePushOptions)(LandingScreen), store, Provider);

The final logs from code-push debug android

[11:31:37] Awaiting user action.
[11:31:42] Downloading package.
[11:31:43] An unknown error occurred.
[11:31:43] Update is invalid - A JS bundle file named "null" could not be found within the downloaded contents. Please check that you are releasing your CodePush updates using the exact same JS bundle file name that was shipped with your app's binary.
Trevor Watson
  • 415
  • 1
  • 8
  • 20

2 Answers2

2

It appears the react-native linker is putting some things in the wrong class

public class MainApplication extends NavigationApplication {


private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this)     
{
  @NonNull
  @Override
  public String getJSBundleFile() {
    return CodePush.getJSBundleFile();
  }

The override should be on MainApplication, not the ReactNativeHost

public class MainApplication extends NavigationApplication {

  @NonNull
  @Override
  public String getJSBundleFile() {
    return CodePush.getJSBundleFile();
  }

private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this)            
{ /*... */ }
Trevor Watson
  • 415
  • 1
  • 8
  • 20
0

You have to Override it inside the ReactGateway createReactGateway(){} method.

That's works for me.

@Override
protected ReactGateway createReactGateway() {
    ReactNativeHost host = new NavigationReactNativeHost(this, isDebug(), createAdditionalReactPackages()) {
        @Override
        protected String getJSMainModuleName() {
            return "index";
        }

        @NonNull
        @Override
        public String getJSBundleFile() {
            return CodePush.getJSBundleFile();
        }
    };
    return new ReactGateway(this, isDebug(), host);
}
Trọng Nguyễn Công
  • 1,207
  • 1
  • 10
  • 23