GithubHelp home page GithubHelp logo

android-imagesweep's Introduction

ImageSweep

ImageSweep is a python script used to remove unused drawables from your application. During the build process, all indexed .pngs inside of 'drawable' folders get crunched so that their size is much much smaller; However, even unused images get bundled with your apk. This means that your apk is potentially much much larger than it needs to be even after compression.

##Usage python image_sweep.py project_src_directory

Where project_src_directory is the relative or absolute file-path where your source code lives. Make sure the chosen directory contains ALL of your source code / AndroidManifest.xml, but none of the libraries you've included (the script auto-determines where the /res folder is and libraries can potentially break that).

##Requirements This script has been tested on Python 2.7 and Python 3.0. Works with all versions of Android.

##How It Works At a high level, the script scans each file and does a search for 'R.drawable.' or "@drawable/". Afterwards it checks each resource inside of drawable folders to see if it was referenced anywhere.

How Well Does it Work

In the 'Canvas for Android' project, we were able to cut about 46% off the raw apk size and 26% off the installed app size. It works best as a supplement to ProGuard.

##Warnings!

  • This script only works for top-level projects that aren't referenced from other projects.
  • The files deleted cannot be reversed. Please only run this script on projects located in source control. Just in case.

android-imagesweep's People

Contributors

hhoang avatar joshruesch avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

android-imagesweep's Issues

backup capability

hi,
thanks for the script, it is very handy.
I add backup capability to android-ImageSweep, if you interested I will submit pull request.

thanks

I can't use it

Hi,

I'm trying to use this tool but I don't understand how it work, that is:

I type this on a terminal (I'm in Windows)
G:\Download>python ImageSweep.py G:\Folder_Projects\Project

(where "Project" is the root folder of my Eclipse project)

but I get the error message

File "....\Download\ImageSweep.py", line 73
print 'Usage: "python ImageSweep.py project_src_directory"'
SyntaxError: invalid syntax

Could you explain me the correct sintax with an example, please?

Thank you in advance.

Kind regards,

Federico

mipmap-* folders not supported

Image files in the res\mipmap-* folders are erased even though I have references to @mipmap/id in my layout xml files.

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.