【问题标题】:Code-Push with React-Native bundle is always null带有 React-Native 捆绑包的 Code-Push 始终为空
【发布时间】:2018-03-28 17:32:01
【问题描述】:

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

【问题讨论】:

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


    【解决方案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)            
    { /*... */ }
    

    【讨论】:

    • 抛出错误:method does not override or implement a method from a supertype @Override
    【解决方案2】:

    您必须在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);
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-08-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-01-15
      • 2019-02-06
      相关资源
      最近更新 更多