1

I have been developing a much-revamped version of an earlier android application. So many additions and changes to the infrastructure, UI, and general organization were necessary that it was far easier to start from scratch with the new application and transplant some of the guts from the old one rather than trying to understand everything the previous developer wrote and incrementally perform smaller surgeries.

I have the source code from the previous developer, and it contains several activities, fragments, classes, etc. that I know likely are not being used in the final build. To make the transplant process as easy as possible, is there an easy way to find out which of the above components are simply not being used in the app?

A couple ideas that immediately come to mind are:

  • stepping through everything in a debugger and taking note of which components are used (this seems like a super inefficient and terribly tedious process)
  • add a log message to each component's onCreate/instantiation code and then run through the entire app (more efficient, but still a pain)

Is there an easy way to do this?

  • You could go to every Activity and press "Ctrl + Left click" (on the Acitivity's name in the code) to look for references of usage for each Activity. This is a little less tedious that the options you have in mind, I think... **Edit** I've found that you can do the same with selecting the file in the project structure and pressing "Alt+F7" (Find usage in the context menu). – Eric Martinez Jul 20 '15 at 22:56
  • The problem is that they may be referenced, but those references may reside in dead code, which I know for a fact there is a lot of. Does Android Studio help with identifying dead code too? – Alexander Bolinsky Jul 20 '15 at 23:00
  • I've found this for now http://stackoverflow.com/a/8508494/4933038, this could help you a little bit I think. – Eric Martinez Jul 20 '15 at 23:02

0 Answers0