pushy热更:
发布热更执行这一步骤pushy uploadApk之前需要操作
如果是项目要热更,首先上传包到pushy上步骤如下:
都在进入你自己的工程根目录下执行,就是E:/pure/项目名
1:pushy login
2:pushy createApp
3: pushy selectApp [appId]绑定到当前应用,此时会发现应用的update.json的key的值和appid的值都和
appid一样了
然后上传
4 :pushy uploadApk android/app/build/outputs/apk/release/app-release.apk
发布本地热更:
修改部分功能,然后pushy bundle --platform android
就可以在客户端已经安装的release版本更新然后看新加的东西 了
CodePush热更:
最初创建app以及相关配置未写,这是配置已经有了的app的情况下,发布热更步骤
文档地址:https://docs.microsoft.com/en-us/appcenter/distribution/codepush/cli#releasing-updates
appcenter全局安装的
1 登录账户
C:\Users\Administrator>appcenter login
2:每当您想检查是否已经登录时,都可以运行以下命令来显示当前身份验证会话的电子邮件地址,用户名和显示名称:
C:\Users\Administrator>appcenter profile list
3 :列出已在App Center服务器上注册的所有应用程序
C:\Users\Administrator>appcenter apps list
ownerName/android_项目名-apk
ownerName/ios_项目名-app
4:通过将一个应用程序设置为当前应用程序
C:\Users\Administrator>appcenter apps set-current ownerName/android_项目名-apk
5:检查哪个应用程序被设置为您帐户的当前应用程序
C:\Users\Administrator>appcenter apps get-current
6:在工程目录下发布热更:未指定环境-d <deploymentName>,默认的是-d Staging,版本号就是可以指定需要热更的版本,
目前测试就是1.0.0,因为需要的更新的外网测试版本是1.0.0
E:\reactnativeproject_pure\xxxxxx>appcenter codepush release-react -a ownerName/android_项目名-apk
如下是第六步的日志
Detecting android app version:
Using the target binary version value "1.0.0" from "android\app\build.gradle".
Running "react-native bundle" command:
node node_modules\react-native\local-cli\cli.js bundle --assets-dest C:\Users\AD
MINI~1\AppData\Local\Temp\code-push202113-7960-t1wg29.noft8\CodePush --bundle-ou
tput C:\Users\ADMINI~1\AppData\Local\Temp\code-push202113-7960-t1wg29.noft8\Code
Push\index.android.bundle --dev false --entry-file index.js --platform android
Welcome to React Native!
Learn once, write anywhere
info Writing bundle output to:, C:\Users\ADMINI~1\AppData\Local\Temp\code-push20
2113-7960-t1wg29.noft8\CodePush\index.android.bundle
info Done writing bundle output
info Copying 57 asset files
info Done copying assets
Releasing update contents to CodePush:
Successfully released an update containing the "C:\Users\ADMINI~1\AppData\Local\
Temp\code-push202113-7960-t1wg29.noft8\CodePush" directory to the "Staging" depl
oyment of the "android_项目名-apk" app.
E:\reactnativeproject_pure\xxxxxx>
很疑惑为什么不上传需要热更的apk到热更服务器上,直接可以发布热更包,这是因为在创建app的时候
在build已经配置了CodePushDeploymentKey,如下所示
用户都利用自动创建的Staging和Production环境,并直接做的所有版本中Staging,然后promote从Staging以Production适当的测试后。
如果不指定环境。默认Staging
appcenter codepush deployment list --displayKeys 通过该命令获取两个部署的部署密钥然后添加到配置文件中
reactnative 热更库:react-native-code-push
buildTypes {
debug {
signingConfig signingConfigs.debug
resValue "string", "CodePushDeploymentKey", ""
}
release {
// Caution! In production, you need to generate your own keystore file.
// see https://reactnative.dev/docs/signed-apk-android.
signingConfig signingConfigs.release
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
//这里的key为Productionde的key
resValue "string", "CodePushDeploymentKey", "***************"
}
releaseStaging.initWith(release)
releaseStaging {
//这里的key为Staging的key
resValue "string", "CodePushDeploymentKey", "**************"
matchingFallbacks = ['release']
}
}
以上第六步是发布的Staging模板,下面是发布Release版本:
其中:
E:\reactnativeproject_pure\wecaLive>appcenter codepush release-react -d Production -m --description " 测试更新"
含义是代表测试强制更新,-m就是强制更新标志
如果删除更新记录:
E:\reactnativeproject_pure\wecaLive>appcenter codepush deployment clear Production
运行此命令后,配置为使用其关联的部署密钥接收更新的客户端设备将不再接收已清除的更新
//如果已经经过上面的操作过:默认是登录状态
1: 查看Staging发布记录:E:\reactnativeproject_pure\wecaLive>appcenter codepush deployment history Staging
┌───────┬──────────────────┬────────────
─┬───────────┬─────────────┬────────────
───────────┐
│ Label │ Release Time │ App Version │ Mandatory │ Description │ Insta
ll Metrics │
├───────┼──────────────────┼────────────
─┼───────────┼─────────────┼────────────
───────────┤
│ v1 │ May 19, 11:38 AM │ 1.0.2 │ Yes │ 20210519 │ Activ
e: 11% (2 of 19) │
│ │ │ │ │ │ Insta
lled: 2 │
└───────┴──────────────────┴────────────
─┴───────────┴─────────────┴────────────
───────────┘
2:发布Staging热更,-a <ownerName>/<appName> 未添加是已经设置过, -t不设置默认本地当前版本 E:\reactnativeproject_pure\wecaLive>appcenter codepush release-react -m --descri
ption "添加日历时间选择"
Detecting android app version:
Using the target binary version value "1.0.3" from "android\app\build.gradle".
Running "react-native bundle" command:
node node_modules\react-native\local-cli\cli.js bundle --assets-dest C:\Users\AD
MINI~1\AppData\Local\Temp\code-push2021424-4296-1e1p84k.jjb8\CodePush --bundle-o
utput C:\Users\ADMINI~1\AppData\Local\Temp\code-push2021424-4296-1e1p84k.jjb8\Co
dePush\index.android.bundle --dev false --entry-file index.js --platform android
Welcome to React Native!
Learn once, write anywhere
info Writing bundle output to:, C:\Users\ADMINI~1\AppData\Local\Temp\code-push20
21424-4296-1e1p84k.jjb8\CodePush\index.android.bundle
info Done writing bundle output
info Copying 156 asset files
info Done copying assets
Releasing update contents to CodePush:
Successfully released an update containing the "C:\Users\ADMINI~1\AppData\Local\
Temp\code-push2021424-4296-1e1p84k.jjb8\CodePush" directory to the "Staging" dep
loyment of the "wecalive-apk" app.
╭─────────────────────────────────────
─────╮
│ │
│ Update available 2.7.4 → 2.9.0 │
│ Run yarn add appcenter-cli to update │
│ │
╰─────────────────────────────────────
─────╯
3:查看发布的Staging热更 E:\reactnativeproject_pure\wecaLive>appcenter codepush deployment history Stagin
g
┌───────┬──────────────────┬────────────
─┬───────────┬──────────────────┬───────
────────────────┐
│ Label │ Release Time │ App Version │ Mandatory │ Description │
Install Metrics │
├───────┼──────────────────┼────────────
─┼───────────┼──────────────────┼───────
────────────────┤
│ v1 │ May 19, 11:38 AM │ 1.0.2 │ Yes │ 20210519 │
Active: 10% (2 of 20) │
│ │ │ │ │ │
Installed: 2 │
├───────┼──────────────────┼────────────
─┼───────────┼──────────────────┼───────
────────────────┤
│ v2 │ Just now │ 1.0.3 │ Yes │ 添加日历时间选择 │
No installs recorded │
└───────┴──────────────────┴────────────
─┴───────────┴──────────────────┴───────
────────────────┘
E:\reactnativeproject_pure\wecaLive>
最后如果要测试的话,打包Release包也可以区分Release(Production)和(Staging),在上传渠道包进行调试热更时很有用
cd android
# 生成Release(Production)包
gradlew assembleRelease
# 生成Release(Staging)包
gradlew assembleReleaseStaging
其实都一样,只是环境区别
4:举例发布release版本添加版本号-t和发布禁用-x
appcenter codepush release-react -d Production -t 1.0.5 -m -x (禁用)
appcenter codepush release-react -d Production -t 1.0.5 -m --description "1、优化主页新显示规则;
2、增加新的分类显示;
3、修复部分已知BUG"
这种提示换行的描述不知道命令可不可以,所以通过-x先发布不可用,然后通过账号登录管理后台去手动添加描述