Introduction to the previous part of this paper:
I hope that those who have read this article can have a deep understanding of thermal repair and related technologies and concepts.
I. Brief introduction of Tinker thermal repair scheme
1. Tencent official Introduction:
Tinker is an open source project (Github link). It is the official wechat Hot patch solution for Android. It supports dynamic distribution of code, So library and resources, So that applications can be updated without the need to reinstall.
2. Understanding of Tinker principle
3. Why use hot fixes?
- It’s too expensive for developers to re-release.
- The cost of download and installation is too high, and users may lose patience and uninstall the software directly.
- Bug repair is not timely, poor user experience. (2) Look at the development process of hot repair, which is significantly more flexible.
Several advantages of thermal repair:
- No need to re-issue version, real-time efficiency, development of maintenance costs reduced.
- Patch silent installation, users can realize Bug repair without perception, good experience.
- High repair success rate, minimize the loss.
4. Why do you choose Tencent’s Tinker repair solution?
Reasons to use Tinker:
Tinker hotfix not only supports class, So, and resource replacement, it also supports 2.x to 7.x platform. Tinker can not only be used as a Bugfix, but also as a replacement for feature publishing. Tinker already runs on wechat’s hundreds of millions of Android devices, so why don’t you use it?
(Between you and me: In fact, the best hotfix right now is ali’s new non-invasive Android hotfix, Sophix, released in June 2017, but I started using hotfix technology in the first half of last year, so Tinker was the best choice compared to the hotfix technology on the market at that time. Moreover, it has been used in my actual project, so I think Tinker is a good choice if you haven’t used overheating repair in your project. After all, Tinker has been running on hundreds of millions of Android devices in wechat. For ali’s Sophix, I recommend reading up on How Android HotFix Technology works.)
2. Detailed explanation of Tinker access steps
// TinkerPatch plugin classpath"Com. Tinkerpatch. SDK: tinkerpatch - gradle - plugin: 1.2.6." "
compile "Com. Android. Support: multidex: 1.0.1." "
Copy the code
Add TinkerPatch SDK dependency to build. Gradle app:
compile "Com. Tinkerpatch. SDK: tinkerpatch - the android SDK: 1.2.6." "
Copy the code
Gradle: Tinkerpatch. gradle: Tinkerpatch. gradle: Tinkerpatch. gradle: tinkerpatch.gradle
apply from: 'tinkerpatch.gradle'
Copy the code
Tinkerpatch. gradle = build. Gradle = build. Gradle = build. Gradle = build.
apply plugin: 'tinkerpatch-support'*/ def bakPath = file()"${buildDir}/bakApk/")
def baseInfo = "App - 1.0.0-0527-01-08-12"
def variantName = "release"/ * * * for parsing the refer to the parameters of the plug-in * http://tinkerpatch.com/Docs/SDK * / tinkerpatchSupport {/ * * can shut down in the debug tinkerPatch when / / * * * *disableTinker needs to add multiDexKeepProguard and proguardFiles, these configuration files themselves are automatically added by the tinkerPatch plugin when youdisableYou can copy proguardRules. Pro and TinkerMultidexkeep. pro in this example, you need to manually modify'tinker.sample.android.app'The package name for this example is your own package name, com.xxx prefix package name do not change **/ tinkerEnable =true
reflectApplication = true/** * Whether to enable the hardening mode. This mode can only be used when the APK is about to be hardened; otherwise, the patch will fail. * If you only use hardening on one channel, you can use multiple flavors **/ protectedApp =false/** * Whether the patch supports new activities (The exported attribute of new activities must befalse)
**/
supportComponent = true
autoBackupApkPath = "${bakPath}"
appKey = "When you create your application in the background of TinkPatch, you will have a unique AppKey value, just fill it in here."/** Note: To release a new full package, appVersion must be updated **/ appVersion ="1.0.0"
def pathPrefix = "${bakPath}/${baseInfo}/${variantName}/"
def name = "${project.name}-${variantName}"
baseApkFile = "${pathPrefix}/${name}.apk"
baseProguardMappingFile = "${pathPrefix}/${name}-mapping.txt"
baseResourceRFile = "${pathPrefix}/${name}-R.txt"/ * * * if you have compiled many flavors demand, can consult: https://github.com/TinkerPatch/tinkerpatch-flavors-sample * note: Unless you have a different flavor code, use zip Comment or a file to generate channel information. Walle or packer-ng) **/} /** * Is used to determine whether tinkerPatch is enabled */ Android {defaultConfig {buildConfigField"boolean"."TINKER_ENABLE"."${tinkerpatchSupport.tinkerEnable}"}} /** * Generally speaking, we do not need to make any changes to the following parameters * For detailed description of each parameter, please refer to: * https://github.com/Tencent/tinker/wiki/Tinker-%E6%8E%A5%E5%85%A5%E6%8C%87%E5%8D%97 */ tinkerPatch { 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}}Copy the code
⑤ Hit the benchmark package.
⑦ In TinkerPatch Platform, create your application and release patches:
8. Click pull patch, exit App, restart App, check log, successfully pull patch log and App running effect as shown below:
At this point, Tinker is done. In the actual project, our application is going to be launched in every major application market, so we must make multiple package channels. According to the general rule, we can implement productFlavors. Assuming that the project is going to have 20 channel packages, it is not reasonable to have 20 separate patch packages for each channel package. In response to this demand, Tinker officially provided us with a multi-channel package scheme, as shown in the following figure:
In the next part, I will explain in detail one of the officially recommended schemes: the implementation of Tinker’s multi-channel package scheme combined with Walle. Thermal Repair Technology Practice Tour — TinkerPatch Thermal Repair and Walle Multi-channel packaging (II)
TinkerPatchDemo GitHub
Android hot repair Tinker access and source code analysis – Hongyang MultiDex and hot repair implementation principle