4

Question:

Does anyone have a quick way for removing all the extra resources in an Android application that are not being used(referenced) in my code?

Explanation:

I've noticed that once I finally get one of my Android applications ready to ship, there are usually a lot of unwanted resources within my application. I usually have some extra drawables that aren't being used because I switched them out with new ones. I also have extra String resources and even some extra layouts that aren't used anywhere in my application (there is no reference to them in the java code). I want my applications to take up the least amount of space possible on the user's phone.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129

3 Answers3

9

Yes, the ADT in Eclipse includes something called "android lint".

http://tools.android.com/tips/lint

In a nutshell, it points out problems with your app. One thing it notes is unused resources. It doesn't automatically remove them.

You can access it from Eclipse through (right click project) > android tools > run lint.

Nimantha
  • 6,405
  • 6
  • 28
  • 69
Jeffrey Blattman
  • 22,176
  • 9
  • 79
  • 134
  • 3
    lint does many different checks. if you want only check for unused resources you can do that on the command line: lint --check UnusedResources projectdir – spatialist May 28 '14 at 16:01
  • Lint produces for my project lots of false positives, which is annoying and makes it unusable for me. – Anthea Feb 22 '16 at 11:57
2

besides the builtin Lint: http://code.google.com/p/android-unused-resources/

it can't remove them automatically but it should be able to tell you which resources are unused.

zapl
  • 63,179
  • 10
  • 123
  • 154
0

We build a small tool that will remove all the unused resources from your project based on the android lint output. We think this is more reliable then the android-unused-resources project as we rely on the official lint tool.

https://github.com/KeepSafe/android-resource-remover

philipp
  • 4,133
  • 1
  • 36
  • 35
  • I’ve encountered a few issues with `android-resource-remover`. It doesn’t seem to do a great job catching errors at the moment. Can’t get it to work and I don’t have the time to dabble with it. – Mike Meyer Oct 06 '14 at 08:33
  • @MikeMeyer We're using it for our production app and it works nice. It would be nice if you could open a bug report on Github so we can fix the problems you have. Also feel free to open a PR your self. It's a open source project at the end :) – philipp Oct 07 '14 at 17:17
  • @phillipp Can you please give a details on how can i really android resource remover. I set up python. It comes with pip. then i run this command from cmd setx PATH "%PATH%";C:\Python34\Scripts for pip and it was saved successfully. Then what should i do. Please please help me on that – Omar Faroque Anik May 06 '15 at 19:57
  • I've never used it with Windows. I'm sorry – philipp May 07 '15 at 01:11