从 Android Studio 项目中删除所有未使用的类和方法 [英] Remove all unused classes,methods from Android Studio project
问题描述
我使用了 lint(分析->检查代码...)并找出未使用的方法和资源.Refractor->删除未使用的资源删除了所有未使用的资源,但没有找到任何这样的选项来删除java类和方法.android studio 有没有什么功能或者插件可以去掉所有的java类,代码中没有用到的方法来保存手动折射?
I have used the lint(Analyze->Inspect Code...) and find out unused methods and resources. All the unused resources removed by Refractor->Remove unused Resources but not found any option like this to remove java classes and methods. Is there any feature in the android studio or any Plugin which can remove all the java classes, the methods which are not used in code to save manual refracting?
推荐答案
这可以通过使用内置检查Java | 来实现.声明冗余 |未使用的声明
.
This can be achieved by using the built-in inspection Java | Declaration redundancy | Unused declaration
.
要在整个项目上运行它,请转到 Analyze ->按名称运行检查...
,键入 Unused Declaration
并选择所需的范围.然后仔细检查输出并在需要时将一些类标记为入口点.
To run it on whole project go to Analyze -> Run inspection by name...
, type Unused declaration
and select desired scope.
Then carefully check output and mark some classes as entry points if needed.
现在您可以选择列表中的Unused Declaration
节点并对所有未使用的声明立即执行Safe delete
操作.
Now you can select Unused declaration
node in list and perform Safe delete
action on all unused declarations at once.
对于 Kotlin 也有类似的检查 Kotlin |冗余结构|未使用的符号
.
For Kotlin there is similar inspection Kotlin | Redundant constructs | Unused symbol
.
这篇关于从 Android Studio 项目中删除所有未使用的类和方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!