I believe that code tells you how, but comments tell you why. And comments are really helpful when you decide to create another version of your app. But should I really add comments to my code? I heard that some hackers can decode my app. And comments may help them to understand it!. My question simply is if there's any tool that removes comments from my project when my build type is 'release'? Or if minifyEnabled true already does this?
-
1If you do good code, it will be readable and if someone is interested they will be able to understand it regardless of your comments. – Lucas Wieloch Jul 09 '19 at 11:56
-
I believe that there's no way can protect your code 100%, but some tools can help, like minifyEnabled that shortens and changes the names of methods and optimizes the code, but is there any way to remove all comments when build a release version? – Mohamed Essam Jul 09 '19 at 11:59
4 Answers
Yep it's being secure, and it would be helpful for any other developer works on your code, but he can understand it without comments too if you organized and naming things correctly. if someone can hack your code he wouldn't need your comments to understand it so don't mind about that and be sure to write clean code.

- 463
- 2
- 11
- 29
After working in the industry for a while, I can tell you comments are the most useful aspect of the job. There's nothing quite like opening a file with 15 year old code in it, and having to waste 2 hours wading through the code with out a guide. Write comments to your code! If you can't clearly explain the code in a few comments, you don't understand it yourself!
edit: If someone hacks into your code, they don't need your comments to understand it, I would focus your security concerns in other areas, check out OWASP for the top 10 lists ... https://www.owasp.org/index.php/Top_10-2017_Top_10

- 68
- 8
I recommend reading Uncle Bob's Clean Code: https://www.amazon.com/Clean-Code-Handbook-Software-Craftsmanship/dp/0132350882.
It has a whole chapter dedicated to comments (chapter 4, if i remember well).
And about obfuscating code, Proguard does that job.
A more detailed explanation about the difference between proguard and minifyEnabled here: What's the difference between "minifyEnabled" and "useProguard" in the Android Plugin for Gradle?

- 49
- 4
*if there's any tool that removes comments from my project *, the android compiler actually ignores all of your comments inside your Java files.
When your Java files are compiled into Java classes they are compiled without the comments, the compiler ignores them you can say.
So don't worry about comments in your code.

- 7,301
- 7
- 25
- 53
-
-
Notice that I am only talking about java files comments, do you have any other comments? Like XML comments? – Tamir Abutbul Jul 09 '19 at 12:13
-