1

我们正在尝试从 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.

  • 反应@16.2.0
  • 反应原生@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.
4

2 回答 2

1

看来 react-native 链接器将一些东西放在错误的类中

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)            
{ /*... */ }
于 2018-03-28T18:00:18.577 回答
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);
}
于 2019-08-26T03:52:15.010 回答