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)