📜 ⬆️ ⬇️

Connecting Android sources to Eclipse

Just yesterday, I stumbled upon a simple and seemingly such an obvious function in IDE Eclipse as connecting sources from external libraries. Maybe it will seem too simple and banal to someone, but after interviewing several familiar developers, I found out that not only did I not know about such a function, because for all amateurs and professionals who develop Android, I ask for the cat, and you will find out How to debug not only your code, but look “at the root” - namely, debug your project “to the bottom”.



I think this picture is annoying to any Android developer (and not only). How offensive it is to look for a mistake for a long time, to monitor the variables and the course of application execution, in the end, to find out that the error occurs in a place that is invisible to you and, therefore, completely beyond the control of and, most likely, not understandable.

It turns out that the developers of Eclipse and Android have provided an excellent opportunity to see the source codes of our libraries (if available, of course) and use them to their fullest potential. This does not apply if the library in the source is imported as a separate project. All of the following applies when the library is in a jar file (this is how the Android API or JDK library is connected).
')
Well, let's start. Click the right mouse button on our project in the Package Explorer and look for the Propreties item (at the very bottom).



Open the properties as shown in the picture and click Edit .



In the menu that opens, select the External folder and look for the daddy with Android sources (in the% android_sdk% / sources / android-% api_version% folder. If there are no sources, run the SDK Manager and download the Sources for Android SDK corresponding to the Target API of your project. As a result, we get just such a thing:



Save the settings, again click the right mouse button on the project folder and select the Resresh item. And now we try to hold down Ctrl and left-click in the text of your program on any Android class. I chose class Activity as a victim .



Thus, you can connect the source (and with them, or instead of them, Java-doc) to any library that provides one or the other as a file or archive. For example, the ORMLite library releases source codes and Java-doc , which are connected in exactly the same way.

That's all. As you can see, this is all done very quickly. And from now on, if the behavior of your hand-held robot becomes mysterious for you, you have a great opportunity to understand the reasons for this behavior, and at the same time to study a little OS sources, which will be only additional advantages in any case.

PS Absolutely the same way you can connect to the source JDK, if you are working purely on Java. To do this, you need to connect the src.zip file to the rt.jar library, located in the root of the folder where your JDK is installed.

From the author: I sincerely hope that this will help many newcomers (and not only) better get used to the Android system.

Source: https://habr.com/ru/post/172491/


All Articles