react native 0.49 android版本热更新
16lz
2021-01-22
版本升级了,发现 老版本的 热更新 用不了,原来是 底层代码 改变了
private void onJSBundleLoadedFromServer(File file) { if (file == null || !file.exists()) { Toast.makeText(this, "no file", Toast.LENGTH_SHORT).show(); return; } // Toast.makeText(this, "Downloading complete", Toast.LENGTH_SHORT).show(); try { //JSCConfig.EMPTY.getConfigMap(); HybridData hb=new HybridData(); ReactApplication application = (ReactApplication) this; Class<?> RIManagerClazz = application.getReactNativeHost().getReactInstanceManager().getClass(); Method method = RIManagerClazz.getDeclaredMethod("recreateReactContextInBackground", JavaScriptExecutorFactory.class, JSBundleLoader.class); method.setAccessible(true); method.invoke(application.getReactNativeHost().getReactInstanceManager(), new JSCJavaScriptExecutorFactory(), JSBundleLoader.createFileLoader(file.getAbsolutePath())); } catch (NoSuchMethodException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } }
更多相关文章
- Android低版本使用ActionBar导入v7-appcompat出现的问题
- 同时兼容高低版本的setBackground跟setTextColor方法
- Android高版本使用照相机报错 Camera error
- 不同Android版本设备正确获取屏幕分辨率的通用方法
- eclipse中修改工程的Android版本
- 【边做项目边学Android】手机安全卫士04_02:从服务器下载并安装新
- 基于Android6.0的RIL底层模块分析
- Android SDK需要ADT 23或更高版本
- Android实现一键复制粘贴,兼容低版本系统(api 11以下)