android 优化Lint清除无效资源文件的用法

鉴于网上有些搜的工具不使。自己整理了下手动清楚的方式。

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>cd D:\tank_eclipse_adt_windows\eclipse_adt_windows\sdk\tools


4.运行此命令后,需要再次找到你的lint.bat工具:命令如下

C:\Users\jinhuan.li>D:

D:\tank_eclipse_adt_windows\eclipse_adt_windows\sdk\tools>lint.bat

5.运行后将会出现下图,则表示进入运行成功:


6. 最重要的一步。进入你的工程目录。并把检索结果输出到你指定的文件中:

  lint --check "UnusedResources" [project_path] > result.txt



7.运行后,出现以下结果表示成功,然后在你指定的文件夹下面,找打生成的文件(指定的文件名)。


android 优化Lint清除无效资源文件的用法_第1张图片


8.打开此文件,则会出现如下的结果。然后自己根据路径,打开eclipse找到对应的文件,删除即可。

res\drawable-hdpi\bg_popup_middle.png: 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]
res\values\colors.xml:8: Warning: The resource R.color.pc_username appears to be unused [UnusedResources]
    #2ba916
           ~~~~~~~~~~~~~~~~~~
res\values\colors.xml:28: Warning: The resource R.color.addreceipt_layout_color appears to be unused [UnusedResources]
    #ededed
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
res\values\colors.xml:34: Warning: The resource R.color.dialog_update_progress_content appears to be unused [UnusedResources]
    #e74b36
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
res\values\colors.xml:49: Warning: The resource R.color.login_regist_tv_color appears to be unused [UnusedResources]
    #4caf50
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
res\values\colors.xml:54: Warning: The resource R.color.banner_indicator_hightlight appears to be unused [UnusedResources]
 #92d050
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
res\values\dimens.xml:6: Warning: The resource R.dimen.common_padding_xsmall appears to be unused [UnusedResources]
    2dp
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
res\values-hdpi\dimens.xml:10: Warning: The resource R.dimen.common_margin_xsmall appears to be unused [UnusedResources]
    2dp
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~
res\values-hdpi\dimens.xml:19: Warning: The resource R.dimen.font_size_small appears to be unused [UnusedResources]
    10sp
           ~~~~~~~~~~~~~~~~~~~~~~
res\values-hdpi\dimens.xml:31: Warning: The resource R.dimen.rating_bar_height_small appears to be unused [UnusedResources]
    18dp
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
res\values\dimens.xml:39: Warning: The resource R.dimen.acc_tv_marginleft appears to be unused [UnusedResources]
    10dp

9.以上如代码所示。红色的部分,即是无效资源所处哪个文件夹下的文件名,或者xml文件中的代码具体行目。


下一篇 ===》》再讲解清除layout文件内无用的代码

如有疑问,欢迎回帖留言。不对之处还请指出,共同讨论学习进步。谢谢。

@Author:金洹。

你可能感兴趣的:(android,cmd,优化,清除无效资源,lint,android)