从Android Studio项目中删除所有未使用的类,方法 [英] Remove all unused classes,methods from Android Studio project
问题描述
我使用了皮棉( Analyze-> Inspect 代码...),并找出了未使用的方法和资源.通过 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 | Declaration redundancy | Unused declaration
来实现.
This can be achieved by using the built-in inspection Java | Declaration redundancy | Unused declaration
.
要在整个项目上运行它,请转到Analyze -> Run inspection by name...
,键入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 | Redundant constructs | Unused symbol
.
For Kotlin there is similar inspection Kotlin | Redundant constructs | Unused symbol
.
这篇关于从Android Studio项目中删除所有未使用的类,方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!