WeHIT / wiki

Small Record In WeHIT Development
0 stars 0 forks source link

React Native 热更新探索 #15

Open rccoder opened 7 years ago

rccoder commented 7 years ago
rccoder commented 7 years ago

安卓打包找不到 ChoreographerCompat

https://github.com/Microsoft/react-native-code-push/issues/792

版本问题

Upgrade RN to 0.43.x version and use react-native-code-push 2.0.x versions Use react-native-code-push 1.17.x versions with RN 0.40-0.42 versions.

rccoder commented 7 years ago

可以在 build 的时候去掉测试

rccoder commented 7 years ago

iOS CodePush 集成

按照官网指导,SDK 直接用 rnpm 集成,提前注册好 CodePush 和 APP,记下 key

参考 CodePush Demo,用 CodePush 包裹 RN 组件

用相关命令导出 bundle,CodePush 发布相关 bundle

Xcode。command + shift + , 选择 release 即可使打 release 包,测试 CodePush 效果。(打包如果测试出现问题,直接在 build 里忽略掉测试)

rccoder commented 7 years ago

Android CodePush 集成

目前存在问题

Caused by: com.microsoft.codepush.react.CodePushNotInitializedException: A CodePush instance has not been created yet. Have you added it to your app's list of ReactPackages?

看官方 Demo,发现 rnpm 修改貌似不完善,修改 MainApplication.java,添加 CodePush:

@Override
    protected List<ReactPackage> getPackages() {
      return Arrays.<ReactPackage>asList(
              new MainReactPackage(),
              new CodePush(getString(R.string.reactNativeCodePush_androidDeploymentKey), getApplicationContext(), BuildConfig.DEBUG),
              new BaiduMapPackage(getApplicationContext())
      );
    }

然后出现:

Could not get BatchedBridge, make sure your bundle is packaged properly” on start of app

参考下面:

react-native run-android 启动:

react-native run-android
react-native start --reset-cache

可以运行了

额外小记

开启 AVD 虚拟机时候出现:

Starting emulator for AVD 'x86_QVGA_Level10'
emulator: device fd:1044
HAX is working and emulator runs in fast virt mode
emulator: Failed to sync vcpu reg
emulator: Failed to sync HAX vcpu context

是 Docker 在跑的问题,关掉就行

rccoder commented 7 years ago
rccoder commented 7 years ago

总结文章 https://github.com/rccoder/blog/issues/27