Coder Social home page Coder Social logo

andresguard's Introduction

AndResGuard

Build Status Jcenter Status Android Arsenal

Read this in other languages: English, 简体中文.

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.

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.

Some uses of AndResGuard are:

  1. Obfuscate android resources. It contains all the resource type(such as drawable、layout、string...). It can prevent your apk from being reversed by Apktool.

  2. Shrinking the apk size. It can reduce the resources.arsc and the package size obviously.

  3. Repackage with 7zip. It supports repackage apk with 7zip, and we can specify the compression method for each file.

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.

Note: Signature schemaV2 will make 7zip compressing invalid. If you really care about your APK size, please disable v2Signing in your signingConfigs

How to use

With Gradle

This has been released on Bintray

apply plugin: 'AndResGuard'

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.tencent.mm:AndResGuard-gradle-plugin:1.2.1'
    }
}

andResGuard {
    // mappingFile = file("./resource_mapping.txt")
    mappingFile = null
    // It will be invalid when you sign apk with schemaV2
    use7zip = true
    useSign = true
    // it will keep the origin path of your resources when it's true
    keepRoot = false
    whiteList = [
        // your icon
        "R.drawable.icon",
        // for fabric
        "R.string.com.crashlytics.*",
        // for umeng update
        "R.string.umeng*",
        "R.string.UM*",
        "R.string.tb_*",
        "R.layout.umeng*",
        "R.layout.tb_*",
        "R.drawable.umeng*",
        "R.drawable.tb_*",
        "R.anim.umeng*",
        "R.color.umeng*",
        "R.color.tb_*",
        "R.style.*UM*",
        "R.style.umeng*",
        "R.id.umeng*",
        // umeng share for sina
        "R.drawable.sina*",
        // for google-services.json
        "R.string.google_app_id",
        "R.string.gcm_defaultSenderId",
        "R.string.default_web_client_id",
        "R.string.ga_trackingId",
        "R.string.firebase_database_url",
        "R.string.google_api_key",
        "R.string.google_crash_reporting_api_key"
    ]
    compressFilePattern = [
        "*.png",
        "*.jpg",
        "*.jpeg",
        "*.gif",
        "resources.arsc"
    ]
    sevenzip {
        artifact = 'com.tencent.mm:SevenZip:1.2.1'
        //path = "/usr/local/bin/7za"
    }
}

If you are using Android Studio, you can find the generate task option in andresguard group. Or alternatively, you run ./gradlew resguard[BuildType | Flavor] in your terminal. The format of task name is as same as assemble.

The sevenzip can be set by path or artifact. Mutiple assignments are allowed, but the winner is always path.

The outputted apk will be stored in {App}/build/output/apk/AndResGuard_{apk_name}/{apk_name}_signed_7zip_aligned.apk.

Looking for more detail

Thanks

Apktool Connor Tumbleson

v2sig @jonyChina162

andresguard's People

Contributors

cnhappier avatar eurstein avatar gitter-badger avatar heruoxin avatar iclinux avatar imknown avatar lizhuangs avatar lzyzsd avatar pranaysharma avatar seven456 avatar shwenzhang avatar simpleton avatar xen0n avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.