Android.mk Add a third-party jar package (reprint)

Source: Internet
Author: User
Tags log4j

Transferred from: www.cnblogs.com/hopetribe/archive/2012/04/23/2467060.html

Local_path:= $ (call My-dir)
Include $ (clear_vars)

Local_static_java_libraries: = xsocket jackson-mapper logging Jackson-core Javatar log4j

Local_module_tags: = Optional

Local_src_files: = $ (call all-subdir-java-files)

Local_package_name: = Test


Local_certificate: = Platform

Include $ (build_package)

##################################################
Include $ (clear_vars)

Local_prebuilt_static_java_libraries: = Xsocket:lib/xsocket-2.8.14.jar \
Jackson-mapper:lib/jackson-mapper-asl-1.6.2.jar\
Logging:lib/commons-logging.jar\
Jackson-core:lib/jackson-core-asl-1.6.2.jar\
Javatar:lib/javatar-2.5.jar\
Log4j:lib/log4j-1.2.15.jar

Include $ (build_multi_prebuilt)

# Use the folloing include to make our test apk.
Include $ (call all-makefiles-under,$ (Local_path))

These are the third-party jar packages required in one of my projects, which refer to the Calculator application in the Android source code, which also refers to a third-party jar package Arity-2.1.2.jar.

It is important to note that there are two key areas to note when you want to refer to more than one jar package.

Local_static_java_libraries: = xsocket jackson-mapper logging Jackson-core Javatar log4j

Local_prebuilt_static_java_libraries: = Xsocket:lib/xsocket-2.8.14.jar \
Jackson-mapper:lib/jackson-mapper-asl-1.6.2.jar \
Logging:lib/commons-logging.jar \
Jackson-core:lib/jackson-core-asl-1.6.2.jar \
Javatar:lib/javatar-2.5.jar \
Log4j:lib/log4j-1.2.15.jar

Xsocket jackson-mapper Logging Jackson-core Javatar log4j These are just names that can be taken casually. The local_prebuilt_static_java_libraries behind is the place where it really works. Such as:

Xsocket:lib/xsocket-2.8.14.jar refers to Xsocket-2.8.14.jar in the Lib directory.

Also note is: = Do not write the + = Oh.

Attached: Writing various types of android.mk, the source I forgot, is the previous browsing is copied down. If you violate the author's rights, please contact me [email protected]. I deleted it in time.

One, compile a simple apk

Local_path: = $ (call My-dir)
Include $ (clear_vars)
# Build All Java files in the Java subdirectory
Local_src_files: = $ (call all-subdir-java-files)
# Name of the APK to build
Local_package_name: = LocalPackage
# Tell it to build an APK
Include $ (build_package)

Second, compile an apk that relies on the static. jar file.

Local_path: = $ (call My-dir)
Include $ (clear_vars)
# List of static libraries to include in the package
Local_static_java_libraries: = Static-library
# Build All Java files in the Java subdirectory
Local_src_files: = $ (call all-subdir-java-files)
# Name of the APK to build
Local_package_name: = LocalPackage
# Tell it to build an APK
Include $ (build_package)
Note: Local_static_java_libraries should be followed by the jar file name of the JAVA library required by your APK program.

Third, compile an apk that requires platform key signature

Local_path: = $ (call My-dir)
Include $ (clear_vars)
# Build All Java files in the Java subdirectory
Local_src_files: = $ (call all-subdir-java-files)
# Name of the APK to build
Local_package_name: = LocalPackage
Local_certificate: = Platform
# Tell it to build an APK
Include $ (build_package)
Note: Local_certificate should be followed by the file name of the signature files

Iv. compiling an apk that requires a special vendor key signature

Local_path: = $ (call My-dir)
Include $ (clear_vars)
# Build All Java files in the Java subdirectory
Local_src_files: = $ (call all-subdir-java-files)
# Name of the APK to build
Local_package_name: = LocalPackage
Local_certificate: = Vendor/example/certs/app
# Tell it to build an APK
Include $ (build_package)

V. Load an ordinary third-party APK

Local_path: = $ (call My-dir)
Include $ (clear_vars)
# Module name should match apk name to be installed.
Local_module: = Localmodulename
Local_src_files: = $ (local_module). apk
Local_module_class: = APPS
Local_module_suffix: = $ (Common_android_package_suffix)
Local_certificate: = Platform
Include $ (build_prebuilt)

Six, loading needs. So (Dynamic library) third-party apk

Local_path: = $ (My-dir)
Include $ (clear_vars)
Local_module: = baiduinput_android_v1.1_1000e
Local_src_files: = $ (local_module). apk
Local_module_class: = APPS
Local_module_suffix: = $ (Common_android_package_suffix)
Local_certificate: = Platform
Include $ (build_prebuilt)

#################################################################
####### Copy the library to/system/lib #########################
#################################################################
Include $ (clear_vars)
Local_module: = libinputcore.so
Local_module_class: = shared_libraries
Local_module_path: = $ (target_out_shared_libraries)
Local_src_files: = lib/$ (Local_module)
Override_build_module_path: = $ (target_out_intermediate_libraries)
Include $ (build_prebuilt)

Vii. compiling a static Java library

Local_path: = $ (call My-dir)
Include $ (clear_vars)
# Build All Java files in the Java subdirectory
Local_src_files: = $ (call all-subdir-java-files)
# Any libraries the This library depends on
Local_java_libraries: = Android.test.runner
# The name of the jar file to create
Local_module: = sample
# Build a static jar file.
Include $ (build_static_java_library)
Note: local_java_libraries represents the jar file name of the generated JAVA library.

Android.mk Add a third-party jar package (reprint)

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.