问题
I am trying to debug some code related to ListView on Samsung Captivate (Galaxy S). I put breakpoint somewhere in my code and when it stops I go back on the stack few frames to the ListView source.
Now, I can expect that there would be some mismatch as my phone probably has slightly different version of Android classes than source code that I use in my IDE. However, I get a discrepancy of over 300 lines. I don't see this discrepancy on emulator.
More over, stack trace shows ListView line number 3688 for method performItemClick() while ListView source only has 3644 lines and this method appears in it on line 3395. I looked at different versions of Android code and none of them has performItemClick() much closer to line 3688.
The only explanation I can think of is that Samsung changed Android code so much, but I can't see why would they do such change.
Is there some other reason that I am missing? Is there any way to force debugger to adjust lines automatically as currently I just can't step through this code?
回答1:
Trying different versions won't help. Samsung modifies their framework code and they do not release the changes. I ran into the same problem with my Samsung Charge smartphone. They probably deal with the Galaxy in the same way. This is an unfortunate reality of the Apache license.
When I contacted Samsung about the issue I got the following response (with minor edits):
FRG83 android-2.2.1_r1 is [the right version number for the Samsung Charge].
Also, ''ListView.java'' file does not match between file on the phone and google original, because we modified it.
ListView.java is covered under Apache license which has no obligation to publish source code.
Please understand that we only publish open source codes that are covered licenses which have obligation of publishing.(ex. GPL, LGPL, MPL...etc).
The reason for mentioning ''Get android open source'' is only for build our Open source code.
回答2:
It's possible that there are encoding differences that cause the number of carriage returns to vary. Try formatting the source with a single encoding and stripping out the excess line breaks.
回答3:
I usually find that reading the documentation is more productive than stepping through 3rd party code if you want to understand it. Especially with big frameworks. There is also a good video on ListView
that I would recommend.
That being said, sometimes even after you've read the documentation it still doesn't make sense and seeing it for real can help. The first thing to do is find out exactly which version you do have on your phone:
my phone probably has slightly different version of Android
and make sure your Android source code attached to eclipse is the same version. If the Android guys added new APIs to ListView
it is perceivable that it could jump in size.
I, too, would be very surprised if Samsung modified these files.
来源:https://stackoverflow.com/questions/6084538/stepping-through-android-code-on-the-phone-big-line-number-discrepancy