0

I know this is a very unusual question but bear with me.

I have been handed a project that was developed by someone very new to Android. The project has 135 Java files. A lot of them are not getting used in the app I'm sure of that.

What I want to know is, is there any way to check which files are being used without testing every function of the app a hundred times?

2
  • I suggest you getting all the methods from all the classes programatically and then searching in files for occurrences. Not the best solution, but it might help.
    – d1e
    Jul 2, 2012 at 10:35
  • You may have luck with proguard. Proguard can run over an compiled Android App and strip away unused code. It can also print some informations about the code that was stripped away. But it has the same problems as the compiler in finding this unused code. It can give you a starting point but will not find everything.
    – Janusz
    Jul 2, 2012 at 10:35

2 Answers 2

3

Build your code and include ProGuard in the build steps; ProGuard will discard unused classes / methods (except those which it has been configured to retain, such as the ones Android is likely to need retained). The examine ProGuard's logged output to see what it did, and manually remove those methods / classes.

0

This is not the solution but a good trick to mantain your code clean and indented:

In order to clean the import section, importing just what you actually use, press:

for mac

 CMD + SHIFT + O  

or for windows

 CTRL + SHIFT + O

In order to indent your code and your layout, press:

for mac

 CMD + SHIFT + F  

or for windows

 CTRL + SHIFT + F

I repeat it, this is not the solution of your problem, but it can help a lot!

2
  • As it's not the solution, it shouldn't be posted as an answer, but rather as a comment.
    – mah
    Jul 2, 2012 at 10:40
  • I do not think this is even relevant as a comment. Try to avoid straying off topic. Jul 2, 2012 at 11:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.