{"id":13537548,"url":"https://github.com/shwenzhang/AndResGuard","last_synced_at":"2025-04-02T04:31:01.023Z","repository":{"id":37664666,"uuid":"44050066","full_name":"shwenzhang/AndResGuard","owner":"shwenzhang","description":"proguard resource for Android  by wechat team","archived":false,"fork":false,"pushed_at":"2023-10-20T04:14:07.000Z","size":8343,"stargazers_count":8585,"open_issues_count":166,"forks_count":1541,"subscribers_count":269,"default_branch":"master","last_synced_at":"2025-03-27T14:01:48.237Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/shwenzhang.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":"SECURITY.md","support":null,"governance":null}},"created_at":"2015-10-11T11:48:06.000Z","updated_at":"2025-03-26T12:08:54.000Z","dependencies_parsed_at":"2022-07-14T04:00:34.613Z","dependency_job_id":"95488adf-7b93-4187-8f87-80539a854083","html_url":"https://github.com/shwenzhang/AndResGuard","commit_stats":null,"previous_names":[],"tags_count":39,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shwenzhang%2FAndResGuard","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shwenzhang%2FAndResGuard/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shwenzhang%2FAndResGuard/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shwenzhang%2FAndResGuard/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shwenzhang","download_url":"https://codeload.github.com/shwenzhang/AndResGuard/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246757042,"owners_count":20828817,"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-08-01T09:01:00.320Z","updated_at":"2025-04-02T04:30:56.014Z","avatar_url":"https://github.com/shwenzhang.png","language":"Java","funding_links":[],"categories":["Unity-Build","Java","Libs","Security"],"sub_categories":["HUD","\u003cA NAME=\"Tools\"\u003e\u003c/A\u003eTools"],"readme":"# AndResGuard\n\n[![Build Status](https://travis-ci.org/shwenzhang/AndResGuard.svg?branch=master)](https://travis-ci.org/shwenzhang/AndResGuard)\n[ ![Download](https://api.bintray.com/packages/wemobiledev/maven/com.tencent.mm%3AAndResGuard-core/images/download.svg) ](https://bintray.com/wemobiledev/maven/com.tencent.mm%3AAndResGuard-core/_latestVersion)\n[![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-AndResGuard-green.svg?style=true)](https://android-arsenal.com/details/1/3034)\n\n*Read this in other languages: [English](README.md), [简体中文](README.zh-cn.md).*\n\n`AndResGuard` is a tooling for reducing your apk size, it works like the `ProGuard` for Java source code, but only aim at the resource files. It changes `res/drawable/wechat` to `r/d/a`, and renames the resource file `wechat.png` to `a.png`. Finally, it repackages the apk with 7zip, which can reduce the package size obviously.\n\n`AndResGuard` is fast, and it does **NOT** need the source codes. Input an Android apk, then we can get a 'ResGuard' apk in a few seconds.\n\nSome uses of `AndResGuard` are:\n\n1. Obfuscate android resources. It contains all the resource type(such as drawable、layout、string...). It can prevent your apk from being reversed by `Apktool`.\n\n2. Shrinking the apk size. It can reduce the `resources.arsc` and the package size obviously.\n\n3. Repackage with `7zip`. It supports repackage apk with `7zip`, and we can specify the compression method for each file.\n\n`AndResGuard` is a command-line tool, it supports Windows, Linux and Mac. We suggest you to use 7zip in Linux or Mac platform for a higher compression ratio.\n\n## How to use\n### With Gradle\nThis has been released on `Bintray`\n```gradle\napply plugin: 'AndResGuard'\n\nbuildscript {\n    repositories {\n        jcenter()\n        google()\n    }\n    dependencies {\n        classpath 'com.tencent.mm:AndResGuard-gradle-plugin:1.2.21'\n    }\n}\n\nandResGuard {\n    // mappingFile = file(\"./resource_mapping.txt\")\n    mappingFile = null\n    use7zip = true\n    useSign = true\n    // It will keep the origin path of your resources when it's true\n    keepRoot = false\n    // If set, name column in arsc those need to proguard will be kept to this value\n    fixedResName = \"arg\"\n    // It will merge the duplicated resources, but don't rely on this feature too much.\n    // it's always better to remove duplicated resource from repo\n    mergeDuplicatedRes = true\n    whiteList = [\n        // your icon\n        \"R.drawable.icon\",\n        // for fabric\n        \"R.string.com.crashlytics.*\",\n        // for google-services\n        \"R.string.google_app_id\",\n        \"R.string.gcm_defaultSenderId\",\n        \"R.string.default_web_client_id\",\n        \"R.string.ga_trackingId\",\n        \"R.string.firebase_database_url\",\n        \"R.string.google_api_key\",\n        \"R.string.google_crash_reporting_api_key\",\n        \"R.string.project_id\",\n    ]\n    compressFilePattern = [\n        \"*.png\",\n        \"*.jpg\",\n        \"*.jpeg\",\n        \"*.gif\",\n    ]\n    sevenzip {\n        artifact = 'com.tencent.mm:SevenZip:1.2.21'\n        //path = \"/usr/local/bin/7za\"\n    }\n\n    /**\n    * Optional: if finalApkBackupPath is null, AndResGuard will overwrite final apk\n    * to the path which assemble[Task] write to\n    **/\n    // finalApkBackupPath = \"${project.rootDir}/final.apk\"\n\n    /**\n    * Optional: Specifies the name of the message digest algorithm to user when digesting the entries of JAR file\n    * Only works in V1signing, default value is \"SHA-1\"\n    **/\n    // digestalg = \"SHA-256\"\n}\n```\n\n### Wildcard\nThe whiteList and compressFilePattern support wildcard include ? * +.\n\n```\n?\tZero or one character\n*\tZero or more of character\n+\tOne or more of character\n```\n\n### WhiteList\nYou need put all resource which access via `getIdentifier` into whiteList.\n**You can find more whitsList configs of third-part SDK in [white_list.md](doc/white_list.md). Welcome PR your configs which is not included in white_list.md**\n\nThe whiteList only works on the specsName of resources, it wouldn't keep the path of resource.\nIf you wanna keeping the path, please use `mappingFile` to implement it.\n\nFor example, we wanna keeping the path of icon, we need add below into our `mappingFile`.\n```\nres path mapping:\n    res/mipmap-hdpi-v4 -\u003e res/mipmap-hdpi-v4\n    res/mipmap-mdpi-v4 -\u003e res/mipmap-mdpi-v4\n    res/mipmap-xhdpi-v4 -\u003e res/mipmap-xhdpi-v4\n    res/mipmap-xxhdpi-v4 -\u003e res/mipmap-xxhdpi-v4\n    res/mipmap-xxxhdpi-v4 -\u003e res/mipmap-xxxhdpi-v4\n```\n\n### How to Launch\nIf you are using `Android Studio`, you can find the generate task option in ```andresguard``` group.\nOr alternatively, you run ```./gradlew resguard[BuildType | Flavor]``` in your terminal. The format of task name is as same as `assemble`.\n\n### Sevenzip\nThe `sevenzip` in gradle file can be set by `path` or `artifact`. Multiple assignments are allowed, but the winner is **always** `path`.\n\n### Result\nIf finalApkBackupPath is null, AndResGuard will overwrite final APK to the path which assemble[Task] write. Otherwise, it will store in the path you assigned.\n\n### Other\n[Looking for more detail](doc/how_to_work.md)\n\n\n## Known Issue\n1. The first element of list which returned by `AssetManager#list(String path)` is empty string when you're using the APK which is compressed by 7zip. [#162](https://github.com/shwenzhang/AndResGuard/issues/162)\n\n## Best Practise\n1. Do **NOT** add `resources.arsc` into `compressFilePattern` unless the app size is really matter to you.([#84](https://github.com/shwenzhang/AndResGuard/issues/84) [#233](https://github.com/shwenzhang/AndResGuard/issues/233))\n2. Do **NOT** enable 7zip compression(`use7zip`) when you distribute your APP on Google Play. It'll prevent the file-by-file patch when updating your APP. ([#233](https://github.com/shwenzhang/AndResGuard/issues/233))\n\n\n## Thanks\n[Apktool](https://github.com/iBotPeaches/Apktool) Connor Tumbleson\n\n[v2sig](https://github.com/shwenzhang/AndResGuard/pull/133) @jonyChina162\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshwenzhang%2FAndResGuard","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshwenzhang%2FAndResGuard","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshwenzhang%2FAndResGuard/lists"}