Android SDK compilation-how to add your own source code to android. jar

Source: Internet
Author: User

You need to perform the following steps to re-compile Android. jar with your own API on the basis of successful android source code compilation.

1. add your own source code. Create a folder under the framework/base Directory of the Android source code to save the Code, such as TV. Name the path of the added file in the form of a package, for example,/TV/java/android/TV, the package defined at the beginning of the added java file is the package of the compiled class file.

2. Modify the makefile file

2.1 modify the build/core/pathmap. mk File

Add TV \ to the variable FRAMEWORKS_BASE _ SUBDIRS. The Code is as follows (the statements in the makefile file start with a Tab space)

FRAMEWORKS_BASE_SUBDIRS: = \

$ (Addsuffix/java ,\

Core \

Graphics \

Location \

Media \

Opengl \

Sax \

Telephony \

Wifi \

Vpn \

Keystore \

TV \

)

2.2 modify the frameworks/base/Android. mk File

Add the package name of your source code, such as android/TV, after the packages_to_document variable. The result is as follows (the statement in the makefile file starts with a Tab space)

Packages_to_document: = \

Android \

Javax/microedition/khronos android/TV

3. Compile with the following command on the ubuntu command line terminal:

Make clean

Make update-api

Make PRODUCT-sdk

The last line can also be replaced by the following two commands:

Make-j4

Make sdk

4. Compilation result

4.1 The directory where the android. jar file is located is

/Out/target/common/obj/PACKAGING/android_jar_intermediates/android. jar and in the/out/target/common/obj/JAVA_LIBRARIES/android_stubs_current_intermediates/src directory, organize all the data generated to android in package format. jar.

4.2 The SDK directory is

Out/host/linux-x86/sdk/, the generated sdk file directory and compressed package is:

Android-sdk_eng.xxx_linux-x86

Android-sdk_eng.xxx_linux-x86.zip (xxx is the file name of your android source code)

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.