React native 如何为android制作关于react本机应用程序的捆绑包
我知道我可以运行'react native bundle'命令为android创建一个包,但我不知道如何让我的应用程序使用包中的资源,而不是dev服务器中的资源。我需要在iOS中编写关于bundle的路径。我应该为android.THX做些什么。根据文档,您可以运行:React native 如何为android制作关于react本机应用程序的捆绑包,react-native,react-native-android,React Native,React Native Android,我知道我可以运行'react native bundle'命令为android创建一个包,但我不知道如何让我的应用程序使用包中的资源,而不是dev服务器中的资源。我需要在iOS中编写关于bundle的路径。我应该为android.THX做些什么。根据文档,您可以运行: react-native bundle --platform android --dev false --entry-file index.android.js --bundle-output android/com/your-c
react-native bundle --platform android --dev false --entry-file index.android.js --bundle-output android/com/your-company-name/app-package-name/src/main/assets/index.android.bundle --assets-dest android/com/your-company-name/app-package-name/src/main/res/
来源:如前所述生成捆绑包,然后: 对于android:(在MainApplication.java中) 对于iOS:(在AppDelegate.m中)
我认为在生产模式下构建realease时,两者也会自动改变。。。但我一直在使用它,以确保它始终使用捆绑包。我知道如何为android创建捆绑包,但我想知道如何让我的android应用程序从捆绑包中获取资源。谢谢
public boolean getUseDeveloperSupport() {
return false;
//return BuildConfig.DEBUG;
}
//debugserver with fallback bundle
// jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index.ios" fallbackResource:nil];
//always bundle
jsCodeLocation = [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];