GithubHelp home page GithubHelp logo

android-resource-cleaner's Introduction

Steps

Produce resources.txt file

resources.txt file is a file that will be generated if we build an app with shrinkResources enabled. It contains information about unused resources that we can remove. To produce it we need to do these:

  1. Empty DFM list in app/build.gradle → dynamicFeatures = []
  2. Enable ShrinkResources in app/build.gradle → shrinkResources = true
  3. Build the app → ./gradlew app:assemble
  4. Wait until the build is successful
  5. Locate resources.txt in app/build/outputs/mapping//resources.txt

Modify resources.txt to the expected format

  1. Remove all lines except line with format Skipped unused resource res/drawable-xxhdpi-v4/ic_launcher_background.png: 767 bytes (replaced with small dummy file of size 67 bytes)
  2. Modify those lines, extract only res/drawable-xxhdpi-v4/ic_launcher_background.png

Run ResourceCleaner.jar

  1. It takes 2 arguments,
  2. First argument is for the path of resources.txt
  3. Second argument is for the path of the android project, if it's not specified the default value for it is "."
  4. The command is java -jar /ResourceCleaner.jar [resources.txt path] [android project path] resources.txt**

Revert changes in Produce resources file step

Try build the project

If the build is failed, there's a possibility that some resources are used by a method or a class that is unused. You can delete the method or the class and try to rebuild again.

Commit, Push and Create PR

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.