explaingit

shwenzhang/andresguard

8,635JavaAudience · developerComplexity · 3/5Setup · moderate

TLDR

An Android Gradle plugin from the WeChat team that shrinks APK file sizes by renaming resource files to very short paths and recompressing with 7zip, while also making assets harder to reverse-engineer.

Mindmap

mindmap
  root((AndResGuard))
    What it does
      APK size reduction
      Resource obfuscation
      7zip recompression
    How it works
      Renames resource paths
      Repackages APK
      Gradle plugin hook
    Config
      Whitelist
      Compression levels
      Mapping file
    Audience
      Android developers
      App release engineers
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Reduce your Android APK download size by running AndResGuard as a Gradle build step that renames and recompresses all resource files.

USE CASE 2

Make your app's image and layout assets harder to inspect and copy by obfuscating the internal resource path structure before publishing.

USE CASE 3

Configure a whitelist of resource names that must stay unchanged at runtime, while letting everything else get renamed for maximum compression.

Tech stack

JavaGradleAndroid7zip

Getting it running

Difficulty · moderate Time to first run · 30min

Requires configuring a whitelist of any resources accessed by string name at runtime, or those resources will break after renaming.

In plain English

AndResGuard is a tool that shrinks the file size of Android app packages. It was created by the WeChat team at Tencent. The basic idea is similar to what ProGuard does for Java source code, except this tool targets resource files instead. ProGuard renames Java classes to shorter names to reduce file size and make the code harder to reverse-engineer, AndResGuard does the same thing for images, layouts, strings, and other assets inside the app package. In practice, the tool takes a finished Android app file (an APK) as input, renames its internal resource folders and files to very short names, and then repackages everything using 7zip compression. For example, a file at the path res/drawable/wechat.png might become r/d/a.png. These short names mean less data in the package index, and combined with stronger 7zip compression the result is a noticeably smaller download for users. The tool serves two related purposes. First, it obfuscates the app's resources, which makes it harder for someone using a tool like Apktool to inspect and copy the app's assets. Second, it reduces the package size, which matters for app stores and user data costs. Both effects come from the same renaming-and-recompressing pass. Developers add AndResGuard to an Android project as a Gradle plugin, which is the standard way to hook into Android's build process. The configuration block lets you specify a white list of resource names to leave unchanged (for resources accessed by string name at runtime, which would break if renamed), set compression levels per file type, choose whether to use 7zip, and optionally provide a mapping file to keep specific folder paths intact. A few practical notes from the README: avoid adding the main resource table file to the compression list unless app size is a top priority, and avoid enabling 7zip when distributing through Google Play, since Google Play uses a file-level patching system for updates that does not work well with 7zip-compressed packages.

Copy-paste prompts

Prompt 1
Show me how to add AndResGuard to my Android project's build.gradle as a Gradle plugin and configure a basic whitelist of resource names to exclude from renaming.
Prompt 2
I want to use AndResGuard with 7zip compression to minimise my APK size. What settings should I use and what should I avoid when distributing through Google Play?
Prompt 3
After running AndResGuard, how can I verify that my app still loads all its resources correctly at runtime, and what is the most common cause of crashes after renaming?
Prompt 4
What is the difference between AndResGuard's resource renaming and ProGuard's code obfuscation, and do I need to run both on the same build?
Prompt 5
My app accesses some resources by their string name at runtime. Show me how to add those resource names to the AndResGuard whitelist so they do not get renamed and break the app.
Open on GitHub → Explain another repo

← shwenzhang on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.