且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

从Android项目中删除所有未使用的资源

更新时间:2022-02-18 10:38:40

由于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.