{"id":16633335,"url":"https://github.com/githubhaohao/tinkersample","last_synced_at":"2025-08-12T02:03:15.855Z","repository":{"id":112624625,"uuid":"78714058","full_name":"githubhaohao/TinkerSample","owner":"githubhaohao","description":"A single sample with Tinker framework.","archived":false,"fork":false,"pushed_at":"2017-01-28T04:59:34.000Z","size":232,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-18T06:11:13.588Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/githubhaohao.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-01-12T06:02:49.000Z","updated_at":"2025-01-02T23:06:20.000Z","dependencies_parsed_at":"2023-06-15T23:00:47.831Z","dependency_job_id":null,"html_url":"https://github.com/githubhaohao/TinkerSample","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/githubhaohao%2FTinkerSample","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/githubhaohao%2FTinkerSample/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/githubhaohao%2FTinkerSample/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/githubhaohao%2FTinkerSample/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/githubhaohao","download_url":"https://codeload.github.com/githubhaohao/TinkerSample/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":235211763,"owners_count":18953498,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-12T05:13:10.586Z","updated_at":"2025-01-23T01:26:57.631Z","avatar_url":"https://github.com/githubhaohao.png","language":"Java","readme":"# TinkerSample\nA single sample with Tinker framework.\n\n[Tinker](https://github.com/Tencent/tinker) is a hot-fix solution library for Android, it supports dex, library and resources update without reinstalling apk.\n\n![tinker.png](https://github.com/Tencent/tinker/raw/master/assets/tinker.png) \n\n## Getting started\nAdd tinker-gradle-plugin as a dependency in your main `build.gradle` in the root of your project:\n\n```gradle\nbuildscript {\n    dependencies {\n        classpath ('com.tencent.tinker:tinker-patch-gradle-plugin:1.7.6')\n    }\n}\n```\n\nThen you need to \"apply\" the plugin and add dependencies by adding the following lines to your `app/build.gradle`.\n\n```gradle\ndependencies {\n    //optional, help to generate the final application \n    provided('com.tencent.tinker:tinker-android-anno:1.7.6')\n    //tinker's main Android lib\n    compile('com.tencent.tinker:tinker-android-lib:1.7.6') \n    compile \"com.android.support:multidex:1.0.1\"\n}\n...\n\n...\napply plugin: 'com.tencent.tinker.patch'\n```\n\nAdd tinkerPatch task.\n\n```gradle\ntinkerPatch {\n\n    oldApk = \"J://tinkerSample/app-debug.apk\"\n    ignoreWarning = true\n    useSign = true\n    buildConfig {\n        applyMapping = null\n        applyResourceMapping = null\n        tinkerId = \"tinkerId\"\n    }\n\n    dex {\n        dexMode = \"jar\"\n        usePreGeneratedPatchDex = false\n        pattern = [\"classes*.dex\",\n                   \"assets/secondary-dex-?.jar\"]\n        loader = [\"com.tencent.tinker.loader.*\",\n                  \"com.jc.tinkersample.SimpleApp\",\n                  \"com.jc.tinkersample.BaseBuildInfo\"\n        ]\n    }\n\n    lib {\n        pattern = [\"lib/armeabi/*.so\"]\n    }\n\n    res {\n        pattern = [\"res/*\", \"assets/*\", \"resources.arsc\", \"AndroidManifest.xml\"]\n        ignoreChange = [\"assets/sample_meta.txt\"]\n        largeModSize = 100\n    }\n\n    packageConfig {\n        configField(\"patchMessage\", \"tinker is sample to use\")\n        configField(\"platform\", \"all\")\n        configField(\"patchVersion\", \"1.0\")\n    }\n\n    sevenZip {\n        zipArtifact = \"com.tencent.mm:SevenZip:1.1.10\"\n    }\n}\n```\n\nCreate a class to extend `DefaultApplicationLike` class.\n\n```java\n@DefaultLifeCycle(\n        application = \"com.jc.tinkersample.SimpleApp\",\n        flags = ShareConstants.TINKER_ENABLE_ALL,\n        loadVerifyFlag = false\n)\npublic class SimpleAppLike extends DefaultApplicationLike {\n    public SimpleAppLike(Application application, int tinkerFlags, boolean tinkerLoadVerifyFlag, long applicationStartElapsedTime, long applicationStartMillisTime, Intent tinkerResultIntent, Resources[] resources, ClassLoader[] classLoader, AssetManager[] assetManager) {\n        super(application, tinkerFlags, tinkerLoadVerifyFlag, applicationStartElapsedTime, applicationStartMillisTime, tinkerResultIntent, resources, classLoader, assetManager);\n    }\n\n    @Override\n    public void onBaseContextAttached(Context base) {\n        super.onBaseContextAttached(base);\n        MultiDex.install(base);\n        TinkerInstaller.install(this);\n    }\n\n    @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)\n    public void registerActivityLifecycleCallbacks(Application.ActivityLifecycleCallbacks callback) {\n        getApplication().registerActivityLifecycleCallbacks(callback);\n    }\n}\n```\nBuild apk and install to your phone. Then copy the `app-debug.apk` to the `oldApk` path.\n\n![app_debug](image/app_debug.png)\n\nFix your bug. Then run `tinkerPatchDebug` task to generate patch (new) apk.\n\n![command](image/command.png)\n\nGenerated `patch_signed_7zip.apk` file.\n\n![new apk](image/new_apk.png)\n\nAccording to specified path, put `patch_signed_7zip.apk` file to your phone (external storage) root diretory. \n\n```java\n        String path = Environment.getExternalStorageDirectory().getAbsolutePath() + \"/patch_signed_7zip.apk\";\n        File file = new File(path);\n        if (file.exists()){\n            Toast.makeText(this, \"patch.apk is existing.\", Toast.LENGTH_SHORT).show();\n            TinkerInstaller.onReceiveUpgradePatch(getApplicationContext(), path);\n        }else{\n            Toast.makeText(this,\"patch.apk is inexistent.\", Toast.LENGTH_SHORT).show();\n        }\n```\n\nDo your hotfix. This is OK!   \n\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgithubhaohao%2Ftinkersample","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgithubhaohao%2Ftinkersample","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgithubhaohao%2Ftinkersample/lists"}