3

If comments in java files are removed as part of apk creation, how the log statements are able to print the correct line number? Could someone please explain? I have seen the same behavior in java files as well when they are compiled.

Raghav
  • 1,014
  • 2
  • 16
  • 34

1 Answers1

7

Comments are not preserved in the APK. The APK contains the compiled byte code for the classes in your application and this byte code does not contain source code comments.

The byte code does preserve some information about the source code, such as method names, to be used when generating stack traces. This may, or may not include accurate line numbers. See:

How can we print line numbers to the log in java

Why some stacktrace do not have line number in java

Community
  • 1
  • 1
Malcolm Smith
  • 3,540
  • 25
  • 29