React Native 热更新Appcenter codepush,Android

记录一下~

热更新 codepush Android

简单命令集

1. 安装appcenter

npm install -g appcenter-cli  
//安装成功后登陆  
appcenter login  

2. 创建app

//groupName 可选,默认创建为账号拥有
appcenter apps create -d  -o   -p 
//举个栗子
appcenter apps create -d MyAndroid -o Android  -p React-Native

3. 创建部署

appcenter codepush deployment add -a / Staging
appcenter codepush deployment add -a / Production
//举个栗子  
appcenter codepush deployment add -a MyGroup/MyAndroid Staging  // 这里的ownerName是你自己的账号名

4. 查看部署

appcenter codepush deployment list -a MyGroup/MyAndroid

┌────────────┬───────────────────────────────────────┐
│ Name │ Key │
├────────────┼───────────────────────────────────────┤
│ Staging │ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX │
├────────────┼───────────────────────────────────────┤
│ Production │ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX │
└────────────┴───────────────────────────────────────┘
后面要用到

到这里,先告一段落,接下来要处理React-Native工程。

5. 安装codepush

项目目录下输入:

npm install --save react-native-code-push  
react-native link react-native-code-push

修改app的build.gradle

android {
    ...
    buildTypes {
        debug {
            ...
            // Note: CodePush updates should not be tested in Debug mode as they are overriden by the RN packager. However, because CodePush checks for updates in all modes, we must supply a key.
            buildConfigField "String", "CODEPUSH_KEY", '""'
            ...
        }

        releaseStaging {
            ...
            buildConfigField "String", "CODEPUSH_KEY", '""'
            ...
        }

        release {
            ...
            buildConfigField "String", "CODEPUSH_KEY", '""'
            ...
        }
    }
    ...
}

6. 发布更新

CLI

appcenter codepush release-react -a / -d  -t  
[-t|--target-binary-version ] 
[-o|--output-dir] 
[-s|--sourcemap-output]
[--plist-file-prefix] 
[-p|--plist-file] 
[-g|--gradle-file] 
[-e|--entry-file] 
[--development] 
[-b|--bundle-name ]
[-r|--rollout ] 
[--no-duplicate-release-error] 
[-k|--private-key-path ] 
[-m|--mandatory] 
[-x|--disabled]
[--description ] 
[-d|--deployment-name ] 
[-a|--app /] 
[--disable-telemetry] 
[-v|--version]
appcenter codepush release-react -a MyGroup/MyAndroid -t 1.0.0 -m --description "1.增加热更新。
2.添加手机登陆注册。"
//查看
appcenter codepush deployment history Staging

7. 正式发布

appcenter codepush promote -a /  
[-t|--target-binary-version ] 
[-r|--rollout ]
[--no-duplicate-release-error]
[-d|--description ]
[-a|--app /] 
[--disable-telemetry]
//举个栗子
appcenter codepush promote -a MyGroup/MyAndroid Staging Production

# Promote the release to production and make it
# available to all versions using that deployment
appcenter codepush promote -a MyGroup/MyAndroid Staging Production -t "*"

8. 回滚

appcenter codepush rollback / 

9. 打补丁

# Mark the latest production release as mandatory
appcenter codepush patch -a /MyApp-iOS Production -m

# Increase the rollout for v23 to 50%
appcenter codepush patch -a /MyApp-iOS Production v23 -rollout 50%

你可能感兴趣的:(React Native 热更新Appcenter codepush,Android)