user2761885
user2761885

Reputation: 337

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?

Upvotes: 5

Views: 3283

Answers (1)

Shawn
Shawn

Reputation: 1593

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

Upvotes: 3

Related Questions