5

Android lint 工具似乎只能检测未使用的资源,但会删除这些资源。有没有办法自动删除那些未使用的资源?

4

1 回答 1

3

2016-05 更新:这是最终解决方案:

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

---旧答案---据我所知没有。

您使用的是 linux/Mac 吗?我自己开发了一个脚本来做到这一点:

布局文件,在布局目录下执行:

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

图片:在项目根目录执行

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
于 2013-10-19T05:56:11.250 回答