鉴于网上有些搜的工具不使。自己整理了下手动清楚的方式。
1. 在Android ADT开发工具包下面, 找到SDK包下的Tools文件夹中,有个lint.bat的脚本工具。
2.如果直接点开Lint.bat工具,出现闪一下就消失。运行不了时,请打开cmd运行命令。
3.通过命令,进入到tools下面。找到lint工具。代码如下:
Microsoft Windows [版本 6.1.7601]
版权所有 (c) 2009 Microsoft Corporation。保留所有权利。
C:\Users\xxx.li><span style="color:#ff0000;">cd D:\tank_eclipse_adt_windows\eclipse_adt_windows\sdk\tools</span>
4.运行此命令后,需要再次找到你的lint.bat工具:命令如下
C:\Users\jinhuan.li><span style="color:#ff0000;">D:</span>
D:\tank_eclipse_adt_windows\eclipse_adt_windows\sdk\tools><span style="color:#ff0000;">lint.bat</span>
5.运行后将会出现下图,则表示进入运行成功:
6. 最重要的一步。进入你的工程目录。并把检索结果输出到你指定的文件中:
lint --check "UnusedResources" [project_path] > result.txt
7.运行后,出现以下结果表示成功,然后在你指定的文件夹下面,找打生成的文件(指定的文件名)。
8.打开此文件,则会出现如下的结果。然后自己根据路径,打开eclipse找到对应的文件,删除即可。
<span style="color:#ff0000;">res\drawable-hdpi\bg_popup_middle.png</span>: Warning: The resource R.drawable.bg_popup_middle appears to be unused [UnusedResources]
res\drawable-hdpi\bg_popup_top_white.9.png: Warning: The resource R.drawable.bg_popup_top_white appears to be unused [UnusedResources]
res\drawable-hdpi\btn_list_down.png: Warning: The resource R.drawable.btn_list_down appears to be unused [UnusedResources]
res\drawable-hdpi\btn_list_up.png: Warning: The resource R.drawable.btn_list_up appears to be unused [UnusedResources]
res\drawable-hdpi\btn_orders_down.png: Warning: The resource R.drawable.btn_orders_down appears to be unused [UnusedResources]
res\drawable-hdpi\btn_orders_up.png: Warning: The resource R.drawable.btn_orders_up appears to be unused [UnusedResources]
res\drawable-hdpi\btn_popup_left_normal.9.png: Warning: The resource R.drawable.btn_popup_left_normal appears to be unused [UnusedResources]
res\drawable-hdpi\btn_popup_left_pressed.9.png.png: Warning: The resource R.drawable.btn_popup_left_pressed appears to be unused [UnusedResources]
res\drawable-hdpi\btn_popup_normal.9.png: Warning: The resource R.drawable.btn_popup_normal appears to be unused [UnusedResources]
res\drawable-hdpi\btn_popup_pressed.9.png: Warning: The resource R.drawable.btn_popup_pressed appears to be unused [UnusedResources]
res\drawable-hdpi\btn_popup_right_normal.9.png: Warning: The resource R.drawable.btn_popup_right_normal appears to be unused [UnusedResources]
res\drawable-hdpi\btn_popup_right_pressed.9.png: Warning: The resource R.drawable.btn_popup_right_pressed appears to be unused [UnusedResources]
<span style="color:#ff0000;">res\values\colors.xml:8</span>: Warning: The resource R.color.pc_username appears to be unused [UnusedResources]
<color name="pc_username">#2ba916</color>
~~~~~~~~~~~~~~~~~~
res\values\colors.xml:28: Warning: The resource R.color.addreceipt_layout_color appears to be unused [UnusedResources]
<color name="addreceipt_layout_color">#ededed</color>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
res\values\colors.xml:34: Warning: The resource R.color.dialog_update_progress_content appears to be unused [UnusedResources]
<color name="dialog_update_progress_content">#e74b36</color>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
res\values\colors.xml:49:</span> Warning: The resource R.color.login_regist_tv_color appears to be unused [UnusedResources]
<color name="login_regist_tv_color">#4caf50</color>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
res\values\colors.xml:54:</span> Warning: The resource R.color.banner_indicator_hightlight appears to be unused [UnusedResources]
<color name="banner_indicator_hightlight">#92d050</color>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<span style="color:#ff0000;">res\values\dimens.xml:6</span>: Warning: The resource R.dimen.common_padding_xsmall appears to be unused [UnusedResources]
<dimen name="common_padding_xsmall">2dp</dimen>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
res\values-hdpi\dimens.xml:10: Warning: The resource R.dimen.common_margin_xsmall appears to be unused [UnusedResources]
<dimen name="common_margin_xsmall">2dp</dimen>
~~~~~~~~~~~~~~~~~~~~~~~~~~~
res\values-hdpi\dimens.xml:19: Warning: The resource R.dimen.font_size_small appears to be unused [UnusedResources]
<dimen name="font_size_small">10sp</dimen>
~~~~~~~~~~~~~~~~~~~~~~
res\values-hdpi\dimens.xml:31: Warning: The resource R.dimen.rating_bar_height_small appears to be unused [UnusedResources]
<dimen name="rating_bar_height_small">18dp</dimen>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
res\values\dimens.xml:39: Warning: The resource R.dimen.acc_tv_marginleft appears to be unused [UnusedResources]
<dimen name="acc_tv_marginleft">10dp</dimen>
9.以上如代码所示。红色的部分,即是无效资源所处哪个文件夹下的文件名,或者xml文件中的代码具体行目。
下一篇 ===》》再讲解清除layout文件内无用的代码。
如有疑问,欢迎回帖留言。不对之处还请指出,共同讨论学习进步。谢谢。
@Author:金洹。