{"id":13429338,"url":"https://github.com/alibaba/AndFix","last_synced_at":"2025-03-16T03:31:19.655Z","repository":{"id":37821083,"uuid":"42489883","full_name":"alibaba/AndFix","owner":"alibaba","description":"AndFix is a library that offer hot-fix for Android App.","archived":false,"fork":false,"pushed_at":"2020-11-17T03:34:10.000Z","size":15890,"stargazers_count":6979,"open_issues_count":242,"forks_count":1598,"subscribers_count":448,"default_branch":"master","last_synced_at":"2025-03-13T19:06:11.788Z","etag":null,"topics":["android","hotfix"],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/alibaba.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-09-15T02:26:39.000Z","updated_at":"2025-03-02T14:39:54.000Z","dependencies_parsed_at":"2022-08-19T11:21:12.275Z","dependency_job_id":null,"html_url":"https://github.com/alibaba/AndFix","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/alibaba%2FAndFix","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alibaba%2FAndFix/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alibaba%2FAndFix/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alibaba%2FAndFix/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alibaba","download_url":"https://codeload.github.com/alibaba/AndFix/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243822312,"owners_count":20353496,"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":["android","hotfix"],"created_at":"2024-07-31T02:00:35.403Z","updated_at":"2025-03-16T03:31:19.626Z","avatar_url":"https://github.com/alibaba.png","language":"C++","funding_links":[],"categories":["HotFix","Index","C++","Hotfix","Projects List"],"sub_categories":["Android Hot Fix"],"readme":"# AndFix\n\n[![Download](https://api.bintray.com/packages/supern/maven/andfix/images/download.svg) ](https://bintray.com/supern/maven/andfix/_latestVersion)\n[![Build Status](https://travis-ci.org/alibaba/AndFix.svg)](https://travis-ci.org/alibaba/AndFix)\n[![Software License](https://rawgit.com/alibaba/AndFix/master/images/license.svg)](LICENSE)\n\n[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/alibaba/AndFix?utm_source=badge\u0026utm_medium=badge\u0026utm_campaign=pr-badge)\n\nAndFix is a solution to fix the bugs online instead of redistributing Android App. It is distributed as [Android Library](https://sites.google.com/a/android.com/tools/tech-docs/new-build-system/aar-format).\n\nAndfix is an acronym for \"**And**roid hot-**fix**\".\n\nAndFix supports Android version from 2.3 to 7.0, both ARM and X86 architecture, both Dalvik and ART runtime, both 32bit and 64bit.\n\nThe compressed file format of AndFix's patch is **.apatch**. It is dispatched from your own server to client to fix your App's bugs.\n\n## Principle\n\nThe implementation principle of AndFix is method body's replacing,\n\n![image](images/principle.png)\n\n### Method replacing\n\nAndFix judges the methods should be replaced by java custom annotation and replaces it by hooking it. AndFix has a native method `art_replaceMethod` in ART or `dalvik_replaceMethod` in Dalvik. \n\nFor more details, [here](https://github.com/alibaba/AndFix/tree/master/jni).\n\n## Fix Process\n\n![image](images/process.png)\n\n## Integration\n\n### How to get?\n\nDirectly add AndFix aar to your project as compile libraries.\n\nFor your maven dependency,\n\n```xml\n\u003cdependency\u003e\n  \t\u003cgroupId\u003ecom.alipay.euler\u003c/groupId\u003e\n  \t\u003cartifactId\u003eandfix\u003c/artifactId\u003e\n  \t\u003cversion\u003e0.5.0\u003c/version\u003e\n  \t\u003ctype\u003eaar\u003c/type\u003e\n\u003c/dependency\u003e\n```\nFor your gradle dependency,\n\n```groovy\ndependencies {\n\tcompile 'com.alipay.euler:andfix:0.5.0@aar'\n}\n```\n\n### How to use?\n\n1. Initialize PatchManager,\n\n```java\npatchManager = new PatchManager(context);\npatchManager.init(appversion);//current version\n```\n\n2. Load patch,\n\n```java\npatchManager.loadPatch();\n```\n\nYou should load patch as early as possible, generally, in the initialization phase of your application(such as `Application.onCreate()`).\n\n3. Add patch,\n\n```java\npatchManager.addPatch(path);//path of the patch file that was downloaded\n```\nWhen a new patch file has been downloaded, it will become effective immediately by `addPatch`.\n\n## Developer Tool\n\nAndFix provides a patch-making tool called **apkpatch**.\n\n### How to get?\n\nThe `apkpatch` tool can be found [here](https://github.com/alibaba/AndFix/raw/master/tools/apkpatch-1.0.3.zip).\n\n### How to use?\n\n* Prepare two android packages, one is the online package, the other one is the package after you fix bugs by coding.\n\n* Generate `.apatch` file by providing the two package,\n\n```\nusage: apkpatch -f \u003cnew\u003e -t \u003cold\u003e -o \u003coutput\u003e -k \u003ckeystore\u003e -p \u003c***\u003e -a \u003calias\u003e -e \u003c***\u003e\n -a,--alias \u003calias\u003e     keystore entry alias.\n -e,--epassword \u003c***\u003e   keystore entry password.\n -f,--from \u003cloc\u003e        new Apk file path.\n -k,--keystore \u003cloc\u003e    keystore path.\n -n,--name \u003cname\u003e       patch name.\n -o,--out \u003cdir\u003e         output dir.\n -p,--kpassword \u003c***\u003e   keystore password.\n -t,--to \u003cloc\u003e          old Apk file path.\n```\n\nNow you get the application savior, the patch file. Then you need to dispatch it to your client in some way, push or pull.\n\nSometimes, your team members may fix each other's bugs, and generate not only one `.apatch`. For this situation, you can\nmerge `.apatch` files using this tool,\n\n```\nusage: apkpatch -m \u003capatch_path...\u003e -o \u003coutput\u003e -k \u003ckeystore\u003e -p \u003c***\u003e -a \u003calias\u003e -e \u003c***\u003e\n -a,--alias \u003calias\u003e     keystore entry alias.\n -e,--epassword \u003c***\u003e   keystore entry password.\n -k,--keystore \u003cloc\u003e    keystore path.\n -m,--merge \u003cloc...\u003e    path of .apatch files.\n -n,--name \u003cname\u003e       patch name.\n -o,--out \u003cdir\u003e         output dir.\n -p,--kpassword \u003c***\u003e   keystore password.\n```\n\n## Running sample\n\n1. Import samplesI/AndFixDemo to your IDE, append AndFixDemo dependencies with AndFix(library project or aar).\n2. Build project, save the package as 1.apk, and then install on device/emulator.\n3. Modify com.euler.test.A, references com.euler.test.Fix.\n4. Build project, save the package as 2.apk.\n5. Use apkpatch tool to make a patch.\n6. Rename the patch file to out.apatch, and then copy it to sdcard.\n7. Run 1.apk and view log.\n\n## Notice\n\n### ProGuard\n\nIf you enable ProGuard, you must save the mapping.txt, so your new version's build can use it with [\"-applymapping\"](http://proguard.sourceforge.net/manual/usage.html#applymapping).\n\nAnd it is necessary to keep classes as follow,\n\n* Native method\n\n\tcom.alipay.euler.andfix.AndFix\n\n* Annotation\n\n\tcom.alipay.euler.andfix.annotation.MethodReplace\n\nTo ensure that these classes can be found after running an obfuscation and static analysis tool like ProGuard, add the configuration below to your ProGuard configuration file.\n\n\n```\n-keep class * extends java.lang.annotation.Annotation\n-keepclasseswithmembernames class * {\n    native \u003cmethods\u003e;\n}\n```\n\n### Self-Modifying Code\n\nIf you use it, such as *Bangcle*. To generate patch file, you'd better to use raw apk.\n\n### Security\n\nThe following is important but out of AndFix's range.\n\n-  verify the signature of patch file\n-  verify the fingerprint of optimize file\n\n## API Documentation\n\nThe libraries javadoc can be found [here](https://rawgit.com/alibaba/AndFix/master/docs/index.html).\n\n## Contact\n\n...\n\n## License\n\n[Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.html)\n\nCopyright (c) 2015, alipay.com\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falibaba%2FAndFix","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falibaba%2FAndFix","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falibaba%2FAndFix/lists"}