Tencent /tinker
Tinker is a hot-fix solution library for Android, it supports dex, library and resources update without reinstall apk.
★ 17,664⑂ 3,334👁 679⑃ 171● 1,627▤ 60
+1
日增长
+2
周增长
+5
月增长
17,664
stars
3,334
forks
679
watchers
171
prs
1,627
issues
60
releases
README
Tinker
中文说明
Tinker is a hot-fix solution library for Android, it supports dex, library and resources update without reinstalling apk.
!tinker.png
Getting started
Add tinker-gradle-plugin as a dependency in your main build.gradle in the root of your project:
gradle
buildscript {
dependencies {
classpath ('com.tencent.tinker:tinker-patch-gradle-plugin:1.9.1')
}
}
Then you need to "apply" the plugin and add dependencies by adding the following lines to your app/build.gradle.
gradle
dependencies {
//optional, help to generate the final application
provided('com.tencent.tinker:tinker-android-anno:1.9.1')
//tinker's main Android lib
compile('com.tencent.tinker:tinker-android-lib:1.9.1')
}
...
...
apply plugin: 'com.tencent.tinker.patch'
If your app has a class that subclasses android.app.Application, then you need to modify that class, and move all its implements to SampleApplicationLike rather than Application:
java
-public class YourApplication extends Application {
+public class SampleApplicationLike extends DefaultApplicationLike {
Now you should change your Application class, make it a subclass of TinkerApplication. As you can see from its API, it is an abstract class that does not have a default constructor, so you must define a no-arg constructor:
java
public class SampleApplication extends TinkerApplication {
public SampleApplication() {
super(
//tinkerFlags, which types is supported
//dex only, library only, all support
ShareConstants.TINKER_ENABLE_ALL,
// This is passed as a string so the shell application does not
// have a binary dependency on your ApplicationLifeCycle class.
"tinker.sample.android.app.SampleApplicationLike");
}
}
Use tinker-android-anno to generate your Application is recommended, you just need to add an annotation for your SampleApplicationLike class
java
@DefaultLifeCycle(
application = "tinker.sample.android.app.SampleApplication", //application name to generate
flags = ShareConstants.TINKER_ENABLE_ALL) //tinkerFlags above
public class SampleApplicationLike extends DefaultApplicationLike
How to install tinker? learn more at the sample SampleApplicationLike.
For proguard, we have already made the proguard config automatic, and tinker will also generate the multiDex keep proguard file for you.
For more tinker configurations, learn more at the sample app/build.gradle.
Ark Support
How to run tinker on the Ark?
building patch
Just use the following command:
buildconfig
bash build_patch_dexdiff.sh old=xxx new=xxx
old indicates the absolute path of android apk(not compiled by Ark) with bugs
new indicates the absolute path of android apk(not compiled by Ark) with fixing
The patch file is packaged in APK.
compiling in Ark
TODO
At present it's compiled by Ark compiler team. The output patch is still packaged in APK format without signature.
packaging the patchTop issues
#1210Java8新特性支持时间74 comments · 2019-09-02#1310编译报主dex超过65536错误28 comments · 2019-12-17#1082请问tinker什么时候能支持java8,目前有些库要求必须是java8了,比如butterknnife24 comments · 2019-04-25#1207Tinker1.9.14,使用了360加固,补丁加载成功后重启crash20 comments · 2019-08-31#1420Warning:ignoreWarning is false, but we found loader classes are found in old secondary dex. Found classes: 18 comments · 2020-06-30#1314【重要】在 Google Play 上发包的开发者请注意!!17 comments · 2019-12-19#1566已解决 补丁只生效一次再次重启APP补丁失效 16 comments · 2021-05-22#1471Could not get unknown property 'manifestOutputDirectory' for task ':app:processDebugManifest' of type com.android.build.gradle.tasks.ProcessMultiApkApplicationManifest.16 comments · 2020-10-13
Latest release
v1.9.15.2 v1.9.15.2 2025-07-07Bugfix & ChangeLog 1. 修复依赖库迁移了maven仓库导致的Tinker Project Sync失败的问题。 2. 修复Dex037新增的ClassDef校验导致patch加载失败的问题。