且构网

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

从Android Studio项目中删除所有未使用的类,方法

更新时间:2021-07-07 10:13:50

这可以通过使用内置检查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.