- Notifications
You must be signed in to change notification settings - Fork3.4k
Tinker is a hot-fix solution library for Android, it supports dex, library and resources update without reinstall apk.
License
Tencent/tinker
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
Tinker is a hot-fix solution library for Android, it supports dex, library and resources update without reinstalling apk.
Add tinker-gradle-plugin as a dependency in your mainbuild.gradle in the root of your project:
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 yourapp/build.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')}......applyplugin:'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 toSampleApplicationLike rather than Application:
-publicclassYourApplicationextendsApplication {+publicclassSampleApplicationLikeextendsDefaultApplicationLike {
Now you should change yourApplication class, make it a subclass ofTinkerApplication. 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:
publicclassSampleApplicationextendsTinkerApplication {publicSampleApplication() {super(//tinkerFlags, which types is supported//dex only, library only, all supportShareConstants.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"); }}
Usetinker-android-anno to generate yourApplication is recommended, you just need to add an annotation for yourSampleApplicationLike class
@DefaultLifeCycle(application ="tinker.sample.android.app.SampleApplication",//application name to generateflags =ShareConstants.TINKER_ENABLE_ALL)//tinkerFlags abovepublicclassSampleApplicationLikeextendsDefaultApplicationLike
How to install tinker? learn more at the sampleSampleApplicationLike.
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 sampleapp/build.gradle.
How to run tinker on the Ark?
Just use the following command:
bash build_patch_dexdiff.sh old=xxx new=xxxoldindicates the absolute path of android apk(not compiled by Ark) with bugsnewindicates the absolute path of android apk(not compiled by Ark) with fixing
The patch file is packaged in APK.
TODO
At present it's compiled by Ark compiler team. The output patch is still packaged in APK format without signature.
For tinker-cli, add the following lines to yourtinker_config.xml. Otherwise, the default configure will be used.
<issueid="arkHot"> <pathvalue="arkHot"/> // path of patch <namevalue="patch.apk"/> // name of patch</issue>
For gradle, add the following lines to yourapp/build.gradle. Otherwise, the default configure will be used.
ark { path="arkHot"// path of patch name="patch.apk"// name of patch}
The patch is compiled by Ark and placed on the above path. all subsequent operations are same as tinker-cli or gradle.
The ultimated patch APK consists of two patch files:
classes.dexfor androidpatch.apkwith so for Ark.
There are some issues which Tinker can't dynamic update.
- Can't update AndroidManifest.xml, such as add Android Component.
- Do not support some Samsung models with os version android-21.
- Due to Google Play Developer Distribution Agreement, we can't dynamic update our apk.
Any problem?
- Learn more fromtinker-sample-android.
- Read thesource code.
- Read thewiki orFAQ for help.
- Contact us for help.
For more information about contributing issues or pull requests, see ourTinker Contributing Guide.
Tinker is under the BSD license. See theLICENSE file for details.
About
Tinker is a hot-fix solution library for Android, it supports dex, library and resources update without reinstall apk.
Topics
Resources
License
Contributing
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.
