我的项目有大量的String和ImageResources,其中许多我认为是未使用的.有什么方法可以找出我的代码当前没有引用这些资源中的哪些?
Ale*_*ang 82
在Android Studio(试用到2.1.3版)中,您只需转到主菜单 - >分析 - >按名称运行检查...,然后选择未使用的资源

(它为你运行Android Lint.)
小智 9
在Android Studio中,有一个可用的快捷方式.
按Ctlr + Alt + Shift + i(或Mac上的Cmd + Alt + Shift + i)
这将打开一个对话框,您可以在其中键入"未使用"以查看许多选项.
我通常输入"未使用的资源"并获得包括布局,字符串,绘图等的列表.
你可以使用lint
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:
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.
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
15358 次 |
| 最近记录: |