使用React-Native包的Code-Push始终为null

时间:2018-03-28 17:32:01

标签: react-native code-push react-native-code-push wix-react-native-navigation

我们正在尝试从Microsoft App Center实施CodePush。我们已经设法达到应用程序下载程序包的程度,并将其解压缩。但是,它始终以响应结束

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

我们对MainApplication.java进行了更改

private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {

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

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()
 );
}

在应用代码中,我们致电

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

来自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.

2 个答案:

答案 0 :(得分:0)

似乎反应原生链接器正在将一些东西放在错误的类中

public class MainApplication extends NavigationApplication {


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

覆盖应该在MainApplication上,而不是ReactNativeHost

public class MainApplication extends NavigationApplication {

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

private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this)            
{ /*... */ }

答案 1 :(得分:0)

您必须在ReactGateway createReactGateway(){}方法内覆盖

这对我有用。

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