Android Studio - automatically removes an unused resource

The lint utilities for Android appear to be able to detect unused resources, but delete those resources. Is there a way to remove these unused resources automatically?

+4
source share
1 answer

Update 2016-05: here's the final solution:

http://tools.android.com/tech-docs/new-build-system/resource-shrinking

--- old answer --- No, as far as I know.

Are you using linux / mac? I myself developed a script to do this:

Layout files, execute in the layout directory:

for f in *; do f=`echo $f | sed 's/.xml//g'`; echo $f; grep layout.$f -r ../../src .. >/dev/null; if [ $? != 0 ]; then rm $f.xml;fi done

Images: run in project root directory

find . -name "*png" -o -name "*jpg" | awk -F/ '{print $NF}'|awk -F. '{print $1}'|sort|uniq > imgs
for f in `cat imgs`; do echo $f; grep drawable.$f -r src res >/dev/null; if [ $? != 0 ]; then find res -name $f.* -exec rm {} \; ;fi; done
+3
source

All Articles