MCPcopy
hub / github.com/Tencent/tinker

github.com/Tencent/tinker @v1.9.15.2 sqlite

repository ↗ · DeepWiki ↗ · release v1.9.15.2 ↗
2,456 symbols 6,690 edges 240 files 634 documented · 26%
README

Tinker

license Release Version PRs Welcome WeChat Approved

中文说明

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:

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.

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:

-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:

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

@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:

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 patch

For tinker-cli, add the following lines to your tinker_config.xml. Otherwise, the default configure will be used.

<issue id="arkHot">
   <path value="arkHot"/>         // path of patch
   <name value="patch.apk"/>      // name of patch
</issue>

For gradle, add the following lines to your app/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.dex for android
  • patch.apk with so for Ark.

Tinker Known Issues

There are some issues which Tinker can't dynamic update.

  1. Can't update AndroidManifest.xml, such as add Android Component.
  2. Do not support some Samsung models with os version android-21.
  3. Due to Google Play Developer Distribution Agreement, we can't dynamic update our apk.

Tinker Support

Any problem?

  1. Learn more from tinker-sample-android.
  2. Read the source code.
  3. Read the wiki or FAQ for help.
  4. Contact us for help.

Contributing

For more information about contributing issues or pull requests, see our Tinker Contributing Guide.

License

Tinker is under the BSD license. See the LICENSE file for details.

Extension points exported contracts — how you extend this code

ByteInput (Interface)
A byte source. [6 implementers]
third-party/aosp-dexutils/src/main/java/com/tencent/tinker/android/dex/util/ByteInput.java
ApplicationLifeCycle (Interface)
This interface is used to delegate calls from main Application object. Implementations of this interface must have a on [7 …
tinker-android/tinker-android-loader-no-op/src/main/java/com/tencent/tinker/entry/ApplicationLifeCycle.java
ApplicationLifeCycle (Interface)
This interface is used to delegate calls from main Application object. Implementations of this interface must have a on [7 …
tinker-android/tinker-android-lib/src/main/java/com/tencent/tinker/entry/ApplicationLifeCycle.java
IDexPatcherLogger (Interface)
(no doc) [6 implementers]
tinker-commons/src/main/java/com/tencent/tinker/commons/dexpatcher/DexPatcherLogger.java
PatchReporter (Interface)
Created by zhangshaowen on 16/3/14. means that it is a newly patch, we would default use UpgradePatch to do the [4 implementers]
tinker-android/tinker-android-lib-no-op/src/main/java/com/tencent/tinker/lib/reporter/PatchReporter.java
MessageHandler (Interface)
(no doc) [8 implementers]
tinker-android/tinker-android-loader/src/main/java/com/tencent/tinker/loader/hotplug/interceptor/HandlerMessageInterceptor.java
IOnScreenOff (Interface)
(no doc) [1 implementers]
tinker-sample-android/app/src/main/java/tinker/sample/android/util/Utils.java
ByteOutput (Interface)
A byte sink. [3 implementers]
third-party/aosp-dexutils/src/main/java/com/tencent/tinker/android/dex/util/ByteOutput.java

Core symbols most depended-on inside this repo

e
called by 190
tinker-android/tinker-android-loader/src/main/java/com/tencent/tinker/loader/shareutil/ShareTinkerLog.java
equals
called by 179
third-party/aosp-dexutils/src/main/java/com/tencent/tinker/android/dex/Code.java
append
called by 166
third-party/aosp-dexutils/src/main/java/com/tencent/tinker/android/utils/SparseIntArray.java
w
called by 146
tinker-android/tinker-android-loader/src/main/java/com/tencent/tinker/loader/shareutil/ShareTinkerLog.java
get
called by 128
tinker-build/tinker-patch-lib/src/main/java/org/jf/dexlib2/builder/BuilderMutableMethodImplementation.java
i
called by 125
tinker-android/tinker-android-loader/src/main/java/com/tencent/tinker/loader/shareutil/ShareTinkerLog.java
position
called by 110
third-party/aosp-dexutils/src/main/java/com/tencent/tinker/android/dex/io/DexDataBuffer.java
exists
called by 91
third-party/aosp-dexutils/src/main/java/com/tencent/tinker/android/dex/TableOfContents.java

Shape

Method 2,082
Class 346
Interface 23
Enum 3
Function 2

Languages

Java99%
Python1%

Modules by API surface

third-party/aosp-dexutils/src/main/java/com/tencent/tinker/android/dex/Dex.java108 symbols
third-party/aosp-dexutils/src/main/java/com/tencent/tinker/android/dex/io/DexDataBuffer.java72 symbols
tinker-build/tinker-patch-lib/src/main/java/org/jf/dexlib2/builder/BuilderMutableMethodImplementation.java59 symbols
tinker-android/tinker-android-loader/src/main/java/com/tencent/tinker/loader/hotplug/ActivityStubs.java54 symbols
tinker-commons/src/main/java/com/tencent/tinker/commons/dexpatcher/util/SparseIndexMap.java49 symbols
tinker-android/tinker-android-loader/src/main/java/com/tencent/tinker/loader/shareutil/ShareTinkerInternals.java41 symbols
tinker-android/tinker-android-lib/src/main/java/com/tencent/tinker/lib/tinker/Tinker.java41 symbols
tinker-android/tinker-android-lib-no-op/src/main/java/com/tencent/tinker/lib/tinker/Tinker.java39 symbols
tinker-android/tinker-android-loader-no-op/src/main/java/com/tencent/tinker/loader/shareutil/ShareTinkerInternals.java37 symbols
tinker-commons/src/main/java/com/tencent/tinker/commons/dexpatcher/util/AbstractIndexMap.java32 symbols
third-party/aosp-dexutils/src/main/java/com/tencent/tinker/android/dx/instruction/InstructionComparator.java30 symbols
third-party/aosp-dexutils/src/main/java/com/tencent/tinker/android/dx/instruction/InstructionCodec.java29 symbols

Used by 1 indexed graphs manifest dependencies, hub-wide

For agents

$ claude mcp add tinker \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact