Add app app in the source tree

Source: Internet
Author: User

Add app app in the source tree

Eclipse,androidstudio compiled by the app add to Android source code, need to add android.mk file in App project.

Common android.mk files are written in the following three ways:

1. Without JNI Local code

(1) Create a new android.mk file under the HelloWorld directory

local_path  :  = $ ( call my-dir) include   $ ( CLEAR_VARS ) local_module_tags   :  = eng local_src_files   :  = $ ( call all-subdir-java-files) local_package_name   :  = helloworld  include   $ ( build_package )  

The local_module_tags's alternate value 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
Select /device/<company>/ <product>/xxxx.mk PRODUCT_PACKAGES Add this project in the list of parameters:

                        HelloWorld

(3) Compile the module
Enter the command in the HelloWorld directory mm -B -j , or switch to the Android source root directory to execute any of the following commands:

$ make HelloWorld $ mmm ``package``/apps/HelloWorld
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 :=HelloWorld    local_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)

JNI: Interface (Java Native Interface)

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Add app app in 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.