揭开黎明之光的秘密,刘润民,贵霜帝国
一、调用android lint命令查找出没有用到的资源,并生成一个清单列表:
命令:lint –check “unusedresources” [project_path] > result.txt
执行完之后会生成一个清单文件,内容如下:
二、使用代码自动删除无用的文件:
public class delaction { public static void main(string[] args) throws ioexception { string projectpath = "***"; bufferedreader reader = new bufferedreader(new filereader("result路径")); string line; int count = 0; while ((line = reader.readline()) != null) { if (line.contains("unusedresources") && !line.contains("res/value") && !line.contains("appcompat")) { count++; int end = line.indexof(":"); if (end != -1) { string file = line.substring(0, end); string f = projectpath + file; boolean flag = new file("【拼出文件完整路径】" + f.replace("***", "")).delete(); system.out.println("【拼出文件完整路径】" + f + "=>del=>" + flag); } } } } }
我们往往要多次重复执行上面的操作,才能真正彻底的清除工程中无用的资源文件。
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持移动技术网。
如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复
Android studio 解决logcat无过滤工具栏的操作
Android Studio 恢复小窗口停靠模式(Docked Mode)
Android studio保存logcat日志到本地的操作
Android Studio快捷键生成TAG、Log.x日志输出介绍
网友评论