设为首页 加入收藏

TOP

Android删除工程中无用的资源文件
2015-07-26 13:14:02 来源: 作者: 【 】 浏览:21
Tags:Android 删除 工程 无用 源文件

Android清除工程中无用的资源文件


命令:lint –check “UnusedResources” [project_path] > result.txt


执行完之后会生成一个清单文件,内容如下:


Android清除工程中无用的资源文件


二、使用代码自动删除无用的文件:


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);
? ? ? ? ? ? ? ? }
? ? ? ? ? ? }
? ? ? ? }
? ? }
}


我们往往要多次重复执行上面的操作,才能真正彻底的清除工程中无用的资源文件。


】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇C语言函数指针与回调函数 下一篇利用Python自动清除Android工程中..

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: