Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android studio - automatically remove unused resource

Android lint tools seems only can detect unused resources but remove those resources. Is there any way to remove those unused resource automatically?

like image 827
user2761885 Avatar asked Oct 21 '22 22:10

user2761885


1 Answers

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 developed a script by myself 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

Pictures: execute 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
like image 170
Shawn Avatar answered Oct 24 '22 00:10

Shawn