Android中集成第三方软件包

来源:互联网 发布:pandas处理json 编辑:程序博客网 时间:2024/04/27 13:33

1.编译一个简单的APK

LOCAL_PATH := $(call my-dir)include $(CLEAR_VARS)# Build all java files in the java subdirectoryLOCAL_SRC_FILES := $(call all-subdir-java-files)# Build all java files in srcLOCAL_SRC_FILES := $(call all-java-files-under, src)# Name of the APK to buildLOCAL_PACKAGE_NAME := LocalPackage# Tell it to build an APKinclude $(BUILD_PACKAGE)

2.编译一个依赖第三方jar包的APK

LOCAL_PATH:= $(call my-dir)include $(CLEAR_VARS)LOCAL_MODULE_TAGS := optionalLOCAL_STATIC_JAVA_LIBRARIES := 第三方Jar包1别名(任意取名)  第三方Jar包2别名(任意取名)LOCAL_SRC_FILES := $(call all-subdir-java-files)LOCAL_PACKAGE_NAME := MyMapsinclude $(BUILD_PACKAGE) include $(CLEAR_VARS)LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES := 第三方Jar包1别名:第三方Jar包1路径 \第三方Jar包1别名:第三方Jar包2路径 LOCAL_MODULE_TAGS := optionalinclude $(BUILD_MULTI_PREBUILT) # Use the following include to make our testapk.include $(callall-makefiles-under,$(LOCAL_PATH))
LOCAL_STATIC_JAVA_LIBRARIES 后面应是你的APK程序所需要的JAVA库的JAR文件名。LOCAL_STATIC_JAVA_LIBRARIES取jar库的别名,可以任意取值;
LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES := jar库的别名:jar文件路径
jar库的别名一定要与LOCAL_STATIC_JAVA_LIBRARIES里所取的别名一致,且不含.jar;
jar文件路径一定要是真实的存放第三方jar包的路径。
使用BUILD_MULTI_PREBUILT编译

3.编译一个需要platform key签名的APK

LOCAL_PATH := $(call my-dir)include $(CLEAR_VARS)# Build all java files in the java subdirectoryLOCAL_SRC_FILES := $(call all-subdir-java-files)# Name of the APK to buildLOCAL_PACKAGE_NAME := LocalPackageLOCAL_CERTIFICATE := platform# Tell it to build an APKinclude $(BUILD_PACKAGE)
LOCAL_CERTIFICATE 后面应该是签名文件的文件名

4.编译一个指定签名的APK

LOCAL_PATH := $(call my-dir)include $(CLEAR_VARS)# Build all java files in the java subdirectoryLOCAL_SRC_FILES := $(call all-subdir-java-files)# Name of the APK to buildLOCAL_PACKAGE_NAME := LocalPackageLOCAL_CERTIFICATE := vendor/example/certs/app# Tell it to build an APKinclude $(BUILD_PACKAGE)

5.装载一个普通的第三方APK

LOCAL_PATH := $(call my-dir)include $(CLEAR_VARS)# Module name should match apk name to be installed.LOCAL_MODULE := LocalModuleNameLOCAL_SRC_FILES := $(LOCAL_MODULE).apkLOCAL_MODULE_CLASS := APPSLOCAL_MODULE_SUFFIX := $(COMMON_ANDROID_PACKAGE_SUFFIX)LOCAL_CERTIFICATE := platforminclude $(BUILD_PREBUILT) 

6.编译一个静态java库

LOCAL_PATH := $(call my-dir)include $(CLEAR_VARS)# Build all java files in the java subdirectoryLOCAL_SRC_FILES := $(call all-subdir-java-files)# Any libraries that this library depends onLOCAL_JAVA_LIBRARIES := android.test.runner# The name of the jar file to createLOCAL_MODULE := sample# Build a static jar file.include $(BUILD_STATIC_JAVA_LIBRARY)

LOCAL_JAVA_LIBRARIES表示生成的java库的jar文件名。

7.编译可执行文件

include $(CLEAR_VARS)LOCAL_MODULE:= 可执行文件名称LOCAL_MODULE_TAGS:= debugLOCAL_MODULE_PATH:= $(TARGET_OUT_OPTIONAL_EXECUTABLES)LOCAL_SRC_FILES:= \./xxx/xxx.cinclude $(BUILD_EXECUTABLE)

8.编译JNI动态库

LOCAL_PATH:= $(call my-dir)include $(CLEAR_VARS)LOCAL_MODULE_TAGS := optional# This is the target being built.LOCAL_MODULE:= libxxx_jni# All of the source files that we will compile.LOCAL_SRC_FILES:= \xxx.cpp # No static libraries.LOCAL_STATIC_LIBRARIES :=LOCAL_LDLIBS += -L$(SYSROOT)/usr/lib -llog# Also need the JNI headers.LOCAL_C_INCLUDES += \$(JNI_H_INCLUDE) \    $(LOCAL_PATH)LOCAL_SHARED_LIBRARIES := \libutils \    libcutils # Don't prelink this library.  For more efficient code, you may want# to add this library to the prelink map and set this to true. However,# it's difficult to do this for applications that are not supplied as# part of a system image.LOCAL_PRELINK_MODULE := falseinclude $(BUILD_SHARED_LIBRARY)

9.编译第三方so库到APK

LOCAL_PATH:= $(call my-dir)include $(CLEAR_VARS)LOCAL_MODULE_TAGS := optionalLOCAL_SRC_FILES := $(call all-java-files-under, src)LOCAL_PACKAGE_NAME := apk包名LOCAL_CERTIFICATE := platformLOCAL_JNI_SHARED_LIBRARIES := 动态库别名include $(BUILD_PACKAGE)include $(CLEAR_VARS)LOCAL_PREBUILT_LIBS :=动态库别名:动态库全路径LOCAL_MODULE_TAGS := optionalinclude $(BUILD_MULTI_PREBUILT) # Use the following include to make our testapk.include $(callall-makefiles-under,$(LOCAL_PATH))

LOCAL_PREBUILT_LIBS := 别名:so文件路径
别名一般是动态库去后缀的名称,so文件路径一定要是真实的存放第三方so文件的路径。
编译拷贝用BUILD_MULTI_PREBUILT。

1 0
原创粉丝点击