The error "source not found" When debugging the Android program should be crazy. Goolge did not include the source code when releasing the SDK, which is a bit confusing, for many people, Git is undoubtedly a raw thing, and all the Java code in the framework adds up to a package, that is, more than 20 MB. Even worse, Android Eclipse plugin (ADT) does not allow us to attach the source code to android. jar in the project properties. Fortunately, Eric Burke finds a way to add source to the SDK. By analyzing the source code of ADT, we know that ADT is under the SDK directory."Sources"Directory to find the source code corresponding to the class, so that we only need to put the source code in the sources directory ADT can automatically find the corresponding source code.
The following question is: which source code should be added to the SDK, and how can we get the source code?
I mentioned in my previous article Android Scripting Environment.Fix_android_sdk.pyScript, used to solve the problem that android cannot be found during ASE compilation. OS. in fact, this script does another thing, that is, traversing the entire <android-source> directory and copying all the Java code to the sources directory of the SDK. As mentioned in CompilingASE of ASE Wiki, compiling ASE requires the Android code tree, and I told you a clever method, that is, you only need to download the snapshot of the tag android-1.5r2 of frameworks/base, because android. OS. the Exec package is in it, which solves the problem of ASE compilation.
Go back and add the source code to the SDK. With the fix_android_sdk.py script (Here we do not need to compile the android. OS. Exec package and add it to android. jar, So I removed this function from the script and click Download the modified script.), If you have downloaded the complete code tree through repo (Note the corresponding version), So everything is very simple. Use the following method to pass the android source code and SDK directory as parameters.
Fix_android_sdk.py <android-source> <android-sdk>
After the execution is complete, a sources directory is generated under the \ platforms \ android-1.5 directory, which contains all the Java code in the android code tree, in addition, each directory is stored according to the package name. When debugging code again, the ADT can find the corresponding source code.
If there is no complete code tree in hand and you want to quickly add the source code to the SDK? After reading the code tree of Android, you will know that in addition to frameworks/base, there are also a lot of framework code in the Dalvik directory, in addition, the commonly used apache http package is located in the external/apache-http directory, so you need to obtain the complete framework source code for debugging, we need to download platform/dalvik from the Android code base at least. git, platform/frameworks/base. git, platform/external/apache-http.git. Decompress the downloaded file to the same directory. The directory structure is random. Then, you can use the fix_android_sdk.py script to extract the Java file. Using this method to extract the source code of the framework is much faster than downloading the entire code, and the extracted results are compared with the complete code tree, only the source code of the Application bundled in Android, which we cannot use during debugging, and the code of jdiff, tagsoup, clearsilver and other packages (I have never touched on these three packages, if you think it is necessary, you can download the source code and add the source code according to the method mentioned above, all of which are under platform/external ).
Finally, if you are too lazy to download the above packages and install the Python execution environment, we will discuss the Source code for Android on android Forum. the jar post is suitable for you. The 10th and 11 floors of the post provide the extracted Android 1.5 SDK source code (although the 100% may not match your SDK, it is always better than the eye-catching source not found), decompress it to the sources directory under your SDK.