我按照官方指南创建了一个可安装的 Android 应用程序。
但是,当./gradlew installRelease
我的 React Fragment 加载后,使用应用程序安装 APK 时会崩溃:
RuntimeException: Could not connect to development server.
我的片段代码看起来像这样,就像集成到 Android教程所建议的那样。
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) {
mReactInstanceManager = ReactInstanceManager.builder()
.setApplication(getActivity().getApplication())
.setBundleAssetName("index.android.bundle")
.setJSMainModuleName("index.android")
.addPackage(new MainReactPackage())
.setUseDeveloperSupport(false) // changes nothing
.setInitialLifecycleState(LifecycleState.RESUMED)
.build();
mReactRootView.startReactApplication(mReactInstanceManager, "HelloWorld", null);
return mReactRootView;
}
你有什么想法我可能做错了吗?即使 App 打包发布,React Native 是否需要开发服务器?我不敢相信.. 我只想让我的应用程序按原样运行。