Android Kernel development: Add new apps to the source tree

Source: Internet
Author: User

This article is the 12th article in the "Android Kernel development" series, the previous article describes how to remove the factory app from the source code, this article on this basis, the detailed introduction of how to add a new app in the Android kernel source tree.


There is also a blog about how to add new apps to the source code, but most of them only introduce the methods of adding apps that do not contain JNI native codes, and this article provides a more comprehensive description of how three different types of apps can be added to the Android kernel source tree.


Assuming the new application name is: HelloWorld, and has been compiled and debugged in Eclipse or Android studio, we have three scenarios below to discuss how to add it to the Android kernel source tree.


1. Without JNI local code


First, select a directory in the Android kernel source to store the HelloWorld application's source code, such as in the/packages/apps directory.


(1) Create a new android.mk file in the HelloWorld directory with the following example:


Local_path:= $ (call My-dir) include $ (clear_vars) Local_module_tags: = Englocal_src_files: = $ (call All-subdir-java-files) Local_package_name: = Helloworldinclude $ (build_package)


Note: The alternate value for Local_module_tags is user,eng,tests,optional, and the tags value used in this example is Eng, so the project is compiled only if the user-specified compilation option is eng.


(2) Configuring makefile, adding new items


This step is in contrast to the Android kernel development: Removing the factory app from the source tree, choosing/device/<company>/<product>/xxxx.mk, or from build/target/ In the product/directory, select a. mk that is "referenced" and add this project in the list of product_packages parameters:


Product_packages: = Deskclock Calculator Calendar Camera2 Email HelloWorld


(3) Compile the module


Enter the MM command in the HelloWorld directory, or switch to the Android source root directory to execute any of the following commands:


$ make HelloWorld $ mmm package/apps/helloworld


The generated apk will be placed in the out/target/product/<product>/system/app/directory.


2. Contains JNI local code


For projects that contain JNI, you need to modify the newly created android.mk as follows:


Local_path:= $ (call My-dir) include $ (clear_vars) Local_module_tags: = Englocal_src_files: = $ (call All-subdir-java-files) Local_package_name: = helloworldlocal_jni_shared_libraries: = Libmynativeinclude $ (BUILD_ Package) include $ (call all-makefiles-under,$ (Local_path))


The android.mk under the JNI directory is as follows (assuming that the JNI Directory has the INC and SRC directories):


Local_path: = $ (call My-dir) include $ (clear_vars) Local_module: = libmynativelocal_src_files: = src/mynative.clocal_c_ Includes + = $ (jni_h_include) Local_c_includes + = $ (Local_path)/incinclude $ (build_shared_library)


3. Contains JNI native code, and local code relies on third-party libraries (. A or so)


Assume that the third party libraries that the local code relies on are: ENCODER.A and decoder.so


(1) Modify the ANDROID,MK under the above JNI directory and add the following two items:


Local_static_libraries: = libencoderlocal_shared_libraries: = Libdecoder


(2) Modify the Android.mk file in the HelloWorld directory


First copy the ENCODER.A and decoder.so to the project root, then modify the Android.mk file, add the following two items:


Include $ (clear_vars) Local_module: = libencoderlocal_src_files: = encoder.alocal_module_tags: = Englocal_module_class : = Static_librarieslocal_module_suffix: =. Ainclude $ (build_prebuilt) include $ (clear_vars) Local_module: = Libdecoderlocal_src_files: = decoder.solocal_module_tags: = Englocal_module_class: = Shared_librarieslocal_module_ SUFFIX: =. Soinclude $ (build_prebuilt)


about how to add a new app in the source tree is introduced here, have any questions or suggestions welcome message or letter [email protected] exchange, or follow my Sina Weibo @ Lu _ June get the latest articles and information.


This article is from the "Shadow Three People" blog, please be sure to keep this source http://ticktick.blog.51cto.com/823160/1674206

Android Kernel development: Add new apps to the source tree

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.