Android SDK compilation-how to add the source code to Android. Jar

Source: Internet
Author: User

Reprinted from http://zhuyonghui116.blog.hexun.com/53467491_d.html

 

The first is how to modify the problem.

Find the following lines in/frameworks/base/Android. mk:

Packages_to_document: =

Add the variable at the end of the value assignment statement

XXXXX (here is the name of your package, such as COM/sina/UI, in fact, here is a part of your source code path in/frameworks/base/<your module>/Java/, as long as it can uniquely match your code)

You can.


The meaning of this addition is that the make system will include our package when making the off-line document.

You can also add other new packages.


The following describes the android make SDK process to explain why this change was made. The investigation was conducted in turn. Please refer to the sequence in which makefile is generated.

First, define the basic target object for SDK building in/frameworks/base/Android. mk.

Which. java files need to generate API documents and their paths.

Then define the final build rules and statements in/build/CORE/droiddoc. mk.


Android uses the javadoc tool to generate all API documents.

The javadoc tool can include a parameter to specify a file that contains the names of all the source files to be generated (full path ).

The content of this file is generated by using the variable in/framework/base/Android. mk. Of course, the files in the intermediates directory generated during build are added to droiddoc. mk.


Another
In addition, javadoc can also specify custom doclet (doclet is a small program developed based on the specific API of javadoc, which is responsible for the actual document input
Android compilation system contains such a doclet called droiddoc. You can find the tool in the/build/tools/droiddoc directory.
All source code.


Zheng
Is the tool that generates HTML at the same time in/out/target/common/obj/java_libraries
/Copy (or regenerate) under android_stubs_current_intermediates will be generated to all
Source code (. Java file ).

This tool re-generates all the source files that generate the document by package in the preceding directory.

Then compile and package it into Android. jar.

Root
According to the above analysis, in fact, the android. jar file is produced after the source files of each published API are reorganized by javadoc.
Therefore, the content of Android. jar is actually controlled by javadoc's notation control and makefile.
For codes that already exist in Android, such as WiFi
Native, you can re-build by modifying the javadoc notation method in the source code to get a new WiFi
Android. jar of the Native Interface (replace the @ hide notation in the source file with another one, and then make Update-API; make
SDK ). For the newly added code, you need to modify the makefile using the above method.



The following is a summary of the knowledge involved in the investigation:

1) Javadoc and doclet. They briefly read the usage and parameters of the tool, and also the source code of the doclet of drioddoc to find out where the. Java source file is generated.

2. makefile
Analysis: Make of Android
The showcommands command can be used with any other target to check what is actually done in the make process. (You need to check how showcommands works.
Implementation, because the information provided by the make-D command is not helpful for finding the problem)

3. when tracking the makefile build process, use $ (warning XXXXX) and $ (error XXXX) you can print the value of the variable in other places except the rules. This method is used to find the place where the list of files to be compiled is actually created.

Related Article

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.