Bugly1.3.6版本热更新基本配置

Bugly主页:https://bugly.qq.com/v2/index

热更新文档:https://bugly.qq.com/docs/user-guide/instruction-manual-android-hotfix/?v=20180709165613

在app module的“build.gradle”文件中添加

// 依赖插件脚本
apply from: 'tinker-support.gradle'

compile "com.android.support:multidex:1.0.1" // 多dex配置

// 集成Bugly热更新aar(本地集成使用方式)
// compile(name: 'bugly_crashreport_upgrade-1.3.2', ext: 'aar')
// 远程仓库集成方式(推荐)
compile 'com.tencent.bugly:crashreport_upgrade:1.3.6'
// 指定tinker依赖版本(注:应用升级1.3.5版本起,不再内置tinker)
compile 'com.tencent.tinker:tinker-android-lib:1.9.9'
//使用NDK库,需要配置
compile 'com.tencent.bugly:nativecrashreport:latest.release'

工程根目录下“build.gradle”文件中添加

// tinkersupport插件(1.0.3以上无须再配置tinker插件)
classpath "com.tencent.bugly:tinker-support:1.1.5"

tinker-support.gradle文件

 apply plugin: 'com.tencent.bugly.tinker-support'

def bakPath = file("${buildDir}/bakApk/")

/**
* 此处填写每次构建生成的基准包目录
*/
def baseApkDir = "app-1108-11-35-14"
/**
* 对于插件各参数的详细解析请参考
*/
tinkerSupport {
// 开启tinker-support插件,默认值true
enable = true
// 指定归档目录,默认值当前module的子目录tinker
autoBackupApkDir = "${bakPath}"
autoGenerateTinkerId = true
// 是否启用覆盖tinkerPatch配置功能,默认值false
// 开启后tinkerPatch配置不生效,即无需添加tinkerPatch
overrideTinkerPatchConfiguration = true

// 编译补丁包时,必需指定基线版本的apk,默认值为空
// 如果为空,则表示不是进行补丁包的编译
// @{link tinkerPatch.oldApk }
//baseApk = "${bakPath}/${baseApkDir}/app-release.apk"
baseApk = "${bakPath}/${baseApkDir}/app-debug.apk"
//baseApk = "${bakPath}/app-1217-14-17-24/app-1.0.0-2018-12-17.apk"

// 对应tinker插件applyMapping
//baseApkProguardMapping = "${bakPath}/${baseApkDir}/app-release-mapping.txt"
baseApkProguardMapping = "${bakPath}/${baseApkDir}/app-debug-mapping.txt"
//baseApkProguardMapping = "${bakPath}/app-1217-14-17-24/app-debug-mapping.txt"

// 对应tinker插件applyResourceMapping
//baseApkResourceMapping = "${bakPath}/${baseApkDir}/app-release-R.txt"
baseApkResourceMapping = "${bakPath}/${baseApkDir}/app-debug-R.txt"
//baseApkResourceMapping = "${bakPath}/app-1217-14-17-24/app-debug-R.txt"

tinkerId = "base-1.0.0"
//tinkerId = "patch-1.0.1"

// buildAllFlavorsDir = "${bakPath}/${baseApkDir}"

// 是否开启加固模式,默认为false
// isProtectedApp = true

enableProxyApplication = false
supportHotplugComponent = true
}
/**
* 一般来说,我们无需对下面的参数做任何的修改
* 对于各参数的详细介绍请参考:
* [https://github.com/Tencent/tinker/wiki/Tinker-%E6%8E%A5%E5%85%A5%E6%8C%87%E5%8D%97](https://github.com/Tencent/tinker/wiki/Tinker-%E6%8E%A5%E5%85%A5%E6%8C%87%E5%8D%97)
*/

tinkerPatch {
//oldApk ="${bakPath}/${appName}/app-release.apk"
ignoreWarning = false
useSign = true
dex {
dexMode = "jar"
pattern = ["classes*.dex"]
loader = []
}
lib {
pattern = ["lib/*/*.so"]
}
res {
pattern = ["res/*", "r/*", "assets/*", "resources.arsc", "AndroidManifest.xml"]
ignoreChange = []
largeModSize = 100
}
packageConfig {
}
sevenZip {
zipArtifact = "com.tencent.mm:SevenZip:1.1.10"
// path = "/usr/local/bin/7za"
}
buildConfig {
keepDexApply = false
//tinkerId = "1.0.1-patch"
//applyMapping = "${bakPath}/${appName}/app-release-mapping.txt" // 可选,设置mapping文件,建议保持旧apk的proguard混淆方式
//applyResourceMapping = "${bakPath}/${appName}/app-release-R.txt" // 可选,设置R.txt文件,通过旧apk文件保持ResId的分配
}
}

编译基准包

修改tinker-support.gradle文件中以下参数

//baseApk = "${bakPath}/${baseApkDir}/app-release.apk"
baseApk = "${bakPath}/${baseApkDir}/app-debug.apk"
//baseApk = "${bakPath}/app-1217-14-17-24/app-1.0.0-2018-12-17.apk"

// 对应tinker插件applyMapping
//baseApkProguardMapping = "${bakPath}/${baseApkDir}/app-release-mapping.txt"
baseApkProguardMapping = "${bakPath}/${baseApkDir}/app-debug-mapping.txt"
//baseApkProguardMapping = "${bakPath}/app-1217-14-17-24/app-debug-mapping.txt"

// 对应tinker插件applyResourceMapping
//baseApkResourceMapping = "${bakPath}/${baseApkDir}/app-release-R.txt"
baseApkResourceMapping = "${bakPath}/${baseApkDir}/app-debug-R.txt"
//baseApkResourceMapping = "${bakPath}/app-1217-14-17-24/app-debug-R.txt"

tinkerId = "base-1.0.0"
//tinkerId = "patch-1.0.1"

双击assembleRelease编译生成基准包
(assembleRelease在右侧gradle下的Tasks/bulid/assembleRelease)

这个会在build/outputs/bakApk路径下生成每次编译的基准包、混淆配置文件、资源Id文件


image.png

根据基线版本生成补丁包(重点)

修改tinker-support.gradle文件中以下参数
注意(baseApk,baseApkProguardMapping,baseApkResourceMapping要修改为基准包存放的路径,且tinkerId一定要修改)

//baseApk = "${bakPath}/${baseApkDir}/app-release.apk"
baseApk = "${bakPath}/${baseApkDir}/app-debug.apk"
//baseApk = "${bakPath}/app-1217-14-17-24/app-1.0.0-2018-12-17.apk"

// 对应tinker插件applyMapping
//baseApkProguardMapping = "${bakPath}/${baseApkDir}/app-release-mapping.txt"
baseApkProguardMapping = "${bakPath}/${baseApkDir}/app-debug-mapping.txt"
//baseApkProguardMapping = "${bakPath}/app-1217-14-17-24/app-debug-mapping.txt"

// 对应tinker插件applyResourceMapping
//baseApkResourceMapping = "${bakPath}/${baseApkDir}/app-release-R.txt"
baseApkResourceMapping = "${bakPath}/${baseApkDir}/app-debug-R.txt"
//baseApkResourceMapping = "${bakPath}/app-1217-14-17-24/app-debug-R.txt"

tinkerId = "base-1.0.0"
//tinkerId = "patch-1.0.1"

双击 buildTinkerPatchRelease编译生成补丁包
( buildTinkerPatchRelease在右侧gradle下的Tasks/tinker-support/buildTinkerPatchRelease)

生成的补丁包在build/outputs/patch目录下


image.png

注意:下发补丁以后,APP必须杀死重新启动才会自动下载补丁包

你可能感兴趣的:(Bugly1.3.6版本热更新基本配置)