React-Native设置自定义包网址

时间:2019-03-29 09:39:16

标签: javascript android react-native

我想在android上设置自定义捆绑包网址。这个主题有question。但是自定义ReactNativeHost不适用于调试模式(该应用尚未发布)。我该怎么办?

public class MainApplication extends Application implements ReactApplication {

  public final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
    @Override
    public boolean getUseDeveloperSupport() {
      return BuildConfig.DEBUG;
    }

    @Override
    protected List<ReactPackage> getPackages() {
      return Arrays.<ReactPackage>asList(
          new MainReactPackage()
      );
    }

    @Override
    protected String getJSMainModuleName() {
      return "index";
    }

    @Override
    @Nullable
    protected String getJSBundleFile() {
      return "sdcard/.../index.android.bundle";
    }
  };

  @Override
  public ReactNativeHost getReactNativeHost() {
    return mReactNativeHost;
  }

  @Override
  public void onCreate() {
    super.onCreate();
    SoLoader.init(this, /* native exopackage */ false);
  }
}

0 个答案:

没有答案