Giter Site home page Giter Site logo

maocanmao / shrinker Goto Github PK

View Code? Open in Web Editor NEW

This project forked from yrom/shrinker

0.0 1.0 0.0 194 KB

Inline constant fields of android R class by asm and transform-api

Home Page: http://yrom.net/blog/2018/01/12/android-gradle-plugin-for-shrinking-fields-in-dex/

License: Apache License 2.0

Java 100.00%

shrinker's Introduction

Shrinker

Shrinker will remove all R.class and R$**.class and all constant integer fields will be inlined by asm and transform-api.

I have post more details on my own blog (in Chinese), click here to check it out.

Usage

version You can get shrinker from jitpack

To apply shrinker to your android application:

Step1. Add it in your buildscript section of app's build.gradle

buildscript {
    repositories {
        //...
        maven { url 'https://jitpack.io' }
    }

    dependencies {
        classpath 'net.yrom:shrinker:0.2.9'
    }
}

Step2. Apply it after the Android plugin

apply plugin: 'com.android.application'
//...
apply plugin: 'net.yrom.shrinker'

NOTE that shrinker plugin requires android gradle build tools version at least 3.0.0 and it will be disabled if run in debug build.

Show case

There is a small test application which depends on so many support libraries, would show how many fields shrinked.

Run with shrinker:

./gradlew :test:assembleRelease -PENABLE_SHRINKER

Run with removeUnusedCode:

android {
    buildTypes {
        release {
            ...
            postprocessing {
                removeUnusedCode = true
            }
        }
    }
    ...
}

Content below counts by dexcount-gradle-plugin

options methods fields classes
origin 22164 14367 2563
shrinker 21979 7805 2392
removeUnusedCode 11338 6655 1296
shrinker & removeUnusedCode 11335 3302 1274

License

Copyright 2017 Yrom

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

shrinker's People

Contributors

yrom avatar

Watchers

James Cloos 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.