tinker
Tinker is a hot-fix solution library for Android, it supports dex, library and resources update without reinstall apk.
Top Related Projects
AndFix is a library that offer hot-fix for Android App.
A small framework to split app into small parts
Nuwa, pure java implementation, can hotfix your android application.
Android Signature V2 Scheme签名下的新一代渠道包打包神器
A hotfix library for Android platform, and not just this...
Quick Overview
Tinker is an Android hot-fix solution library developed by Tencent. It enables developers to fix bugs and update parts of their Android apps without releasing a new version through app stores. This allows for faster bug fixes and feature updates while minimizing user disruption.
Pros
- Fast and efficient bug fixing without full app updates
- Reduces app store review times for minor changes
- Minimizes user disruption and maintains app stability
- Supports multiple Android versions and architectures
Cons
- Requires careful implementation to avoid introducing new bugs
- May face restrictions from some app stores or platforms
- Potential security concerns if not properly managed
- Learning curve for developers new to hot-fix solutions
Code Examples
- Applying a patch:
TinkerInstaller.onReceiveUpgradePatch(getApplicationContext(), "/sdcard/patch_signed_7zip.apk");
This code applies a signed patch file to the current application.
- Configuring Tinker in the Application class:
@Override
public void onCreate() {
super.onCreate();
// Initialize Tinker configuration
TinkerManager.initFastCrashProtect();
TinkerManager.setTinkerApplicationLike(this);
TinkerManager.installTinker(this);
}
This code initializes Tinker in the application's onCreate method.
- Loading a library with Tinker:
if (TinkerLoadLibrary.checkUseTinker()) {
TinkerLoadLibrary.loadArmLibrary(getApplicationContext(), "stlport_shared");
} else {
System.loadLibrary("stlport_shared");
}
This code demonstrates how to load a native library using Tinker, with a fallback to the standard System.loadLibrary method.
Getting Started
- Add Tinker to your project's
build.gradle
:
dependencies {
implementation 'com.tencent.tinker:tinker-android-lib:1.9.14'
annotationProcessor 'com.tencent.tinker:tinker-android-anno:1.9.14'
}
- Apply the Tinker plugin in your app's
build.gradle
:
apply plugin: 'com.tencent.tinker.patch'
- Configure Tinker in your Application class:
public class MyApplication extends TinkerApplication {
public MyApplication() {
super(ShareConstants.TINKER_ENABLE_ALL, "your.application.name.SampleApplicationLike",
"com.tencent.tinker.loader.TinkerLoader", false);
}
}
- Build and run your app, then generate and apply patches as needed using Tinker's command-line tools.
Competitor Comparisons
AndFix is a library that offer hot-fix for Android App.
Pros of AndFix
- Faster patch application, as it directly modifies method implementation in memory
- Smaller patch size, typically only containing modified methods
- No app restart required after applying patches
Cons of AndFix
- Limited compatibility with Android versions and device architectures
- Cannot modify app resources or add new classes
- Less comprehensive bug fixing capabilities compared to Tinker
Code Comparison
AndFix patch application:
AndFix.addPatch(context, path);
Tinker patch application:
TinkerInstaller.onReceiveUpgradePatch(getApplicationContext(), patchPath);
Key Differences
- Patch mechanism: AndFix modifies methods in memory, while Tinker replaces entire DEX files
- Flexibility: Tinker supports more comprehensive changes, including resources and new classes
- Compatibility: Tinker has broader device and Android version support
- Performance: AndFix applies patches faster and with less overhead
- Development ecosystem: Tinker has more active development and a larger community
Both tools aim to provide hot-fix solutions for Android apps, but they differ in their approach and capabilities. AndFix offers quick, lightweight patches for method-level changes, while Tinker provides a more comprehensive solution at the cost of larger patch sizes and potential app restarts.
A small framework to split app into small parts
Pros of Small
- Simpler setup and integration process
- Supports both Android and iOS platforms
- Focuses on modular app development and dynamic loading
Cons of Small
- Less active development and community support
- Limited documentation and examples compared to Tinker
- May not be as suitable for large-scale enterprise applications
Code Comparison
Small:
Small.setBaseUri("https://example.com/updates/");
Small.setUp(this);
Tinker:
TinkerInstaller.install(this,
new DefaultLoadReporter(this),
new DefaultPatchReporter(this),
new DefaultPatchListener(this));
Key Differences
- Small emphasizes modular development and dynamic loading of app components
- Tinker focuses on efficient hot-fixing and patching of Android apps
- Small supports both Android and iOS, while Tinker is Android-specific
- Tinker has more robust documentation and a larger community
- Small offers a simpler integration process, while Tinker provides more advanced features for large-scale applications
Use Cases
- Choose Small for cross-platform modular app development with dynamic loading
- Opt for Tinker when dealing with complex Android apps requiring efficient hot-fixing and patching capabilities
Both projects have their strengths, and the choice depends on specific project requirements and development priorities.
Nuwa, pure java implementation, can hotfix your android application.
Pros of Nuwa
- Focuses on incremental updates, potentially reducing update size and time
- Supports both Java and native code hot-fixing
- Provides a more flexible patching mechanism
Cons of Nuwa
- Less actively maintained compared to Tinker
- Smaller community and fewer resources available
- May have compatibility issues with newer Android versions
Code Comparison
Nuwa patch application:
Nuwa.apply(this);
Tinker patch application:
TinkerInstaller.install(this);
Both projects aim to provide hot-fix solutions for Android applications, but they differ in their approach and implementation. Tinker, developed by Tencent, is more widely adopted and actively maintained, offering robust documentation and community support. It focuses on whole APK patching and has been optimized for performance and stability.
Nuwa, on the other hand, provides a more flexible patching mechanism that allows for incremental updates and supports both Java and native code hot-fixing. However, it has seen less active development in recent years, which may impact its compatibility with newer Android versions and overall reliability.
When choosing between the two, consider factors such as project requirements, team expertise, and long-term maintenance needs. Tinker might be more suitable for larger projects requiring extensive support, while Nuwa could be a good fit for smaller projects needing more granular control over patching.
Android Signature V2 Scheme签名下的新一代渠道包打包神器
Pros of walle
- Simpler implementation and easier to integrate into existing projects
- Supports incremental updates for resources like images and assets
- More flexible configuration options for customizing the build process
Cons of walle
- Less comprehensive hot-fix capabilities compared to Tinker
- Smaller community and fewer third-party plugins available
- May require more manual setup for advanced features
Code Comparison
walle:
WalleConfig config = new WalleConfig.Builder()
.apkPath("path/to/your.apk")
.channelPath("path/to/channel.txt")
.build();
WalleChannelWriter.putChannel(config);
Tinker:
TinkerPatch.Builder builder = new TinkerPatch.Builder(context);
builder.tinkerFlags(0)
.reflectApplication(true)
.loadReporter(new DefaultLoadReporter(context))
.patchReporter(new DefaultPatchReporter(context))
.build();
Both tools aim to improve Android app distribution and updates, but they focus on different aspects. walle specializes in channel packaging and resource updates, while Tinker offers more comprehensive hot-fix solutions. The choice between them depends on specific project requirements and the level of hot-fix functionality needed.
A hotfix library for Android platform, and not just this...
Pros of Amigo
- Supports multiple dex files, allowing for larger applications
- Offers more flexible customization options for hot-fix strategies
- Provides better compatibility with Android 7.0+ due to its multi-dex support
Cons of Amigo
- Less mature and less widely adopted compared to Tinker
- May have a steeper learning curve for developers new to hot-fix solutions
- Limited documentation and community support
Code Comparison
Tinker patch application:
TinkerInstaller.onReceiveUpgradePatch(getApplicationContext(), "/sdcard/patch_signed_7zip.apk");
Amigo patch application:
Amigo.work(this, workLater);
Amigo.workLater(this, apkFile);
Both Tinker and Amigo are Android hot-fix solutions, but they differ in their approach and features. Tinker, developed by Tencent, is more established and widely used, with extensive documentation and community support. It focuses on efficient patching and has a smaller learning curve.
Amigo, developed by Eleme, offers more flexibility and better support for larger applications with multiple dex files. It provides more customization options for hot-fix strategies but may require more effort to implement and has less community support.
When choosing between the two, consider factors such as application size, complexity, and team familiarity with hot-fix solutions. Tinker might be better for simpler projects or teams new to hot-fixing, while Amigo could be advantageous for larger, more complex applications requiring advanced customization.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
Tinker
Tinker is a hot-fix solution library for Android, it supports dex, library and resources update without reinstalling apk.
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 bugsnew
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 androidpatch.apk
with so for Ark.
Tinker Known Issues
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.
Tinker Support
Any problem?
- Learn more from tinker-sample-android.
- Read the source code.
- Read the wiki or FAQ for help.
- 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.
Top Related Projects
AndFix is a library that offer hot-fix for Android App.
A small framework to split app into small parts
Nuwa, pure java implementation, can hotfix your android application.
Android Signature V2 Scheme签 名下的新一代渠道包打包神器
A hotfix library for Android platform, and not just this...
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot