1、项目build.gradle 引入:classpath "com.tencent.bugly:tinker-support:1.1.0"
2、app build.gradle引入依赖
implementation "com.android.support:multidex:1.0.1" // 多dex配置 //注释掉原有bugly的仓库 implementation 'com.tencent.bugly:crashreport_upgrade:1.3.3'
3、新建tinker-support.gradle,与app中的gradle并列,app中build.gradle引入tinker-support.gradle
4、通过gradle打基准包,可以通过基准包加固,或者打多渠道包
5、打补丁包
补丁包路径
6、tinker-support.gradle文件:
apply plugin: 'com.tencent.bugly.tinker-support' def bakPath = file("${buildDir}/bakApk/") /** * 此处填写每次构建生成的基准包目录 */ def baseApkDir = "app-1026-09-18-57" /** * 对于插件各参数的详细解析请参考 */ tinkerSupport { // 开启tinker-support插件,默认值true enable = true // tinkerEnable功能开关 tinkerEnable = true // 自动生成tinkerId, 你无须关注tinkerId,默认为false autoGenerateTinkerId = true // 指定归档目录,默认值当前module的子目录tinker autoBackupApkDir = "${bakPath}" // 是否启用覆盖tinkerPatch配置功能,默认值false // 开启后tinkerPatch配置不生效,即无需添加tinkerPatch overrideTinkerPatchConfiguration = true // 编译补丁包时,必需指定基线版本的apk,默认值为空 // 如果为空,则表示不是进行补丁包的编译 // @{link tinkerPatch.oldApk } baseApk = "${bakPath}/${baseApkDir}/app-release.apk" // 对应tinker插件applyMapping baseApkProguardMapping = "${bakPath}/${baseApkDir}/app-release-mapping.txt" // 对应tinker插件applyResourceMapping baseApkResourceMapping = "${bakPath}/${baseApkDir}/app-release-R.txt" // 打多渠道补丁时指定目录 // buildAllFlavorsDir = "${bakPath}/${baseApkDir}" // 是否使用加固模式,默认为false isProtectedApp = true // 是否采用反射Application的方式集成,无须改造Application enableProxyApplication = true // 是否支持新增非export的Activity(注意:设置为true才能修改AndroidManifest文件) supportHotplugComponent = true } /** * 一般来说,我们无需对下面的参数做任何的修改 * 对于各参数的详细介绍请参考: * https://github.com/Tencent/tinker/wiki/Tinker-%E6%8E%A5%E5%85%A5%E6%8C%87%E5%8D%97 */ tinkerPatch { tinkerEnable = true ignoreWarning = true 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 = "base-2.0.1" } }