Android-makefile with dynamic library, static library, and jar package

Source: Internet
Author: User

In the android development process in Linux, third-party static libraries, dynamic libraries, and jar packages are often used to develop their own applications. So, how can we compile makefiles for such applications?
First, write the makefile with a dynamic library:

12345678910
include $(CLEAR_VARS)LOCAL_MODULE := libfreewrite-jni.so LOCAL_MODULE_CLASS := SHARED_LIBRARIES LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)LOCAL_SRC_FILES := libs/$(LOCAL_MODULE)OVERRIDE_BUILD_MODULE_PATH := $(TARGET_OUT_INTERMEDIATE_LIBRARIES) include $(BUILD_PREBUILT)

Add the above Code to the app's outermost android. the last part of the MK file can be used in other places, but do not destroy the structure of the original code during the addition process, for example, it is incorrect to add the following code containing the jar package to the middle of the code block. It should be placed before and after the code block.
The name of the dynamic library to be added above is: libfreewrite-jni.so
Path:/libs/libfreewrite-jni.so

Second, add the jar package:

123456
include $(CLEAR_VARS)  LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES := libvDm:libs/com.redbend.vdm.jar \    libvDmComm:libs/com.redbend.vdm.comm.jar \    libvDmDdl:libs/com.redbend.vdm.ddl.jar \    libvDmFumo:libs/com.redbend.vdm.fumo.jarinclude $(BUILD_MULTI_PREBUILT)

In the above Code, the role of "libvdm:" should be similar to the reference in the programming language, or renamed. In addition, it seems that the addition of the jar package is the same as that of the static library, or is the jar package itself similar to a static library? A little doubt ......

Third, add a static Library:
The complete Android. MK program below is compiled to generate a. So

1234567891011121314151617181920212223242526
Local_path: = $ (call my-DIR) ### Shared Library include $ (clear_vars) # local source file local_src_files to be compiled: = \ Hisense/com_hisense_inputmethod_csksmartengdecoderservice.cpp local_c_includes + =$ (jni_h_include) local_ldlibs + =-lpthread # to be generated. so dynamic library name local_module: = role: = falselocal_shared_libraries: = libcutils libutils # contains static library role: = libhisensecsk2smartengarm # compile and generate one. so dynamic library include $ (build_shared_library) # indicates that the directory where static libraries is located is/lib/libhisensecsk2smartengarm # The rule is set by LIB/android. MK file definition include $ (local_path)/lib/android. mk

Additionally, the android. mk file in the folder where the static library is located:

123
LOCAL_PATH := $(my-dir) $(call add-prebuilt-files, STATIC_LIBRARIES, libhisensecsk2smartengarm.a)

Original article address

Http://xiaohang.org/2011/04/

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.