I used source code of an android app that we created in the past as a basis for another app (a lot of the functionality is similar, however about 1/3 of the functionality of the original app is removed).
I started by copying the source tree and importing a new project into Eclipse workspace. After that, I deleted some layout and drawable files and a few .java
files - the ones that obviously are not needed in a new app.
Finally, I have compiled and tested the new app. Now I would like to do a more thorough cleanup of the project by deleting pretty much everything that's not used.
What is the best way to find all XML and image files, Java files, strings and colour resources that are not used in the new app? By "not used", I mean that they are not referenced from any of the executing application code (starting from main activity, go to all other files referred from it, files referred from those files - and so on).
The project contains hundreds of Drawables (many of them have versions in HDPI, MDPI and LDPI), around a hundred or so layouts and close to a thousand Java files in a dozen different packages. Therefore, checking them one by one is not an option.
Edit March 2012: The latest version of android SDK's lint
tool identifies unused resources quite well. The issue is to filter the messages about unused resources from hundreds of other messages I got. When I ran link on my medium-sized project, I got over 3,000 warnings from it, most of which I intend to do nothing about, because lint cannot analyse what I do in the code with my XML layouts.
Check out http://code.google.com/p/android-unused-resources/
It's open source, in active development, and created/maintained by a great developer.