Android SDK Compilation--How to add source code to Android.jar, and make principle

Source: Internet
Author: User

The first is how this problem is modified.
In/frameworks/base/android.mk, locate the following line:
Packages_to_document: =
At the end of the assignment statement of the variable is added
XXXXX (here is the name of your package, such as Com/sina/ui, actually here is your source code in/frameworks/base/< your module >/java/The following part of the path, as long as the only match to your code can be)

Can.

The implication of this addition is that the make system includes our package when making off-line document.
And so on, adding other new package can do the same.

Here's an easy way to write down the Android make SDK to explain why you made such a change. The investigation was conducted in turn. The instructions are explained in the order in which they were generated by makefile.
The basic target object for SDK building is defined first in/frameworks/base/android.mk.
Includes which. java files are required to generate the API documentation, along with the path to those documents.
Then the rules and statements for the final build are defined in/BUILD/CORE/DROIDDOC.MK.

Android uses the Javadoc tool to generate all API documentation.
Javadoc This tool can specify a file with a parameter that contains the name (full path) of all the source files to be generated by the document.
The contents of the file are generated by the variables in the/framework/base/android.mk. Of course, the files in the intermediates directory generated during the build process are also added in Droiddoc.mk.

In addition Javadoc can also specify custom Doclet (Doclet is a small program based on Javadoc-specific API development, which is responsible for the actual document output). The Android build system contains such a doclet called Droiddoc. You can find all the source code for the tool in the/build/tools/droiddoc directory.

It is the tool that generates HTML at the same time as the/out/target/common/obj/java_libraries/android_stubs_current_ Intermediates copy (or regenerate) all the source code (. java files) that will be generated into the Android.jar.
The tool regenerates all source files generated by the document into the package organization in the above directory.
It is then compiled and packaged into Android.jar.
According to the above analysis, in fact, the Android.jar file is published by the API source files after Javadoc re-organized after the production. Therefore, the content of Android.jar is actually controlled by Javadoc notation control and makefile. For code that already exists in Android, such as WiFi native, you can build a new Android.jar that contains the WiFi native interface by modifying the Javadoc notation method in the source code (the @ in the source file) Hide this notation for another, then make Update-api;make SDK). For the newly added code, you need to modify the makefile as above.


The following summarizes the knowledge involved in the investigation process:
1) Javadoc and Doclet, a simple look at the use of tools and parameters, in addition to see a bit drioddoc this doclet source code, find out where the generated. Java source files.
2.makefile analysis, the Android make Showcommands command can be used with any other target to see what is actually done in the making process. (It also needs to investigate how this showcommands is implemented, because the information given by make-d is not helpful for finding a problem)
3. When tracking the makefile build process, use $ (warning xxxxx) and $ (error xxxx) to print out the value of the variable in a place other than the rule. This method finds out where the list of files to be compiled is actually established.

Android SDK Compilation--How to add source code to Android.jar, and make principle

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.