从Android项目中删除所有未使用的资源 [英] Remove all unused resources from an android project

查看:359
本文介绍了从Android项目中删除所有未使用的资源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想删除所有未使用的布局,串,可绘,颜色等从我的Andr​​oid res目录中。是否有任何工具,这将使我的文件列表,我可以从我的库中删除,并在细节的文件(例如未使用的字符串项),这些不再使用的元素?

I want to remove all unused layouts, strings, drawables, colors, etc from my Android res directory. Are there any tools that will give me a list of files and I can remove from my repository and elements within specifics files (e.g. unused string entries) that are no longer used?

我使用Eclipse / vim和宁可不要<一个href="http://stackoverflow.com/questions/5824357/is-there-a-tool-to-find-unused-resources-in-an-android-project">install的IntelliJ这个如果可能的话。

I use Eclipse/vim and would rather not install IntelliJ for this if possible.

推荐答案

由于ADT 16,你可以用 Android的皮棉。这实在是令人惊讶的工具。

Since ADT 16 you can use Android Lint. It is really amazing tool.

Android的皮棉是ADT 16(与工具16)一个新的工具来扫描Android项目来源潜在的bug。

Android Lint is a new tool for ADT 16 (and Tools 16) which scans Android project sources for potential bugs.

下面是错误类型的一些例子,它看起来为:

Here are some examples of the types of errors that it looks for:

      
  • 在缺少翻译(和未使用的翻译)
  •   
  • 布局性能问题(所有问题用来寻找旧layoutopt工具,并且更)
  •   
  • 在未使用的资源
  •   
  • 在不一致的数组大小(当阵列中的多种配置中定义)
  •   
  • 访问性和国际问题(硬codeD字符串,缺少contentDescription等)
  •   
  • 图标的问题(如丢失密度,重复的图标,错的大小等)
  •   
  • 在易用性问题(如不能在文本字段中指定的输入型)
  •   
  • 清单错误等等。
  •   
  • Missing translations (and unused translations)
  • Layout performance problems (all the issues the old layoutopt tool used to find, and more)
  • Unused resources
  • Inconsistent array sizes (when arrays are defined in multiple configurations)
  • Accessibility and internationalization problems (hardcoded strings, missing contentDescription, etc)
  • Icon problems (like missing densities, duplicate icons, wrong sizes, etc)
  • Usability problems (like not specifying an input type on a text field)
  • Manifest errors and many more.

然而,它有一些问题(不知道是不是他们已经固定),如果你想删除数百个所谓未使用的资源,我建议你手动编译项目数次资源中删除,以确保林特并没有消除需要的东西。

However, it has some issues (don't know if they're already fixed) and if you want to delete hundreds of supposedly unused resources I'd recommend to manually compile project several times during resource removing to be sure that Lint didn't remove something needed.

这篇关于从Android项目中删除所有未使用的资源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆