Android.mk编译.apk .so .jar .a第三方.apk .so .jar .a的方法

一、编译一个简单的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)

二、编译一个依赖静态.jar文件的APK

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)

注:LOCAL_STATIC_JAVA_LIBRARIES 后面应是你的APK程序所须要的JAVA库的JAR文件名称。

三、编译一个须要platform key签名的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

LOCAL_CERTIFICATE := platform

# Tell it to build an APK

include $(BUILD_PACKAGE)

注:LOCAL_CERTIFICATE 后面应该是签名文件的文件名称

四、编译一个须要特殊vendor key签名的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

LOCAL_CERTIFICATE := vendor/example/certs/app

# Tell it to build an APK

include $(BUILD_PACKAGE)

五、装载一个普通的第三方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)

六、装载须要.so(动态库)的第三方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)

七、编译一个静态java库

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 that 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)

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

来源:http://www.cnblogs.com/hopetribe/archive/2012/04/23/2467060.html

include $(CLEAR_VARS)

LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES := ta:libs/TA4AIDL.jar

include $(BUILD_MULTI_PREBUILT)

以下的代码能够加到任一个文件里:

加入共享库:

LOCAL_MODULE := libffmpeg #库的名字

LOCAL_MODULE_TAGS := optional   #系统内有效。你能够试一下不加这一行就能够看到出错提示信息。

LOCAL_PREBUILT_LIBS := libffmpeg.so #库的路径。

include $(BUILD_MULTI_PREBUILT) #这行比較重要是实际做事的地方。參考此文:加入第三方库到Android源代码中

加入静态库:

include $(CLEAR_VARS)

LOCAL_MODULE := libavcodec

LOCAL_PREBUILT_LIBS := libavcodec.a

LOCAL_MODULE_TAGS := optional

include $(BUILD_MULTI_PREBUILT)

静态库和动态库是相应的,静态库是在链接时使用,动态库是在执行时使用。用法:

在要用到相应库的模块的Android.mk文件里增加类似于以下的内容:

静态库(链接时用。它会被拷贝到out/target/product/generic/obj/STATIC_LIBRARIES/libavcodec_intermediates/文件夹下):

LOCAL_WHOLE_STATIC_LIBRARIES += \

libavcodec  #这个是模块名(LOCAL_MODULE)

动态库(执行时用。它会被拷贝到/system/lib/文件夹下。):

LOCAL_SHARED_LIBRARIES += \

libffmpeg

include $(call all-makefiles-under,$(LOCAL_PATH)) #这句上调用子文件夹下的非常有Android.mk

来源:http://hi.baidu.com/2400xiaobing/item/ffa78cd51f76d81521e25085

LOCAL_STATIC_JAVA_LIBRARIES := ta

include $(CLEAR_VARS)

LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES := ta:libs/TA4AIDL.jar

include $(BUILD_MULTI_PREBUILT)

时间: 2024-10-13 11:42:12

Android.mk编译.apk .so .jar .a第三方.apk .so .jar .a的方法的相关文章

Android.mk编译APK范例

转载:http://hubingforever.blog.163.com/blog/static/1710405792011656434982/ 以下仅是使用Android.mk编译APK程序的一些范例. 如果你想了解Android.mk的更多内容请参考<Android.mk简介> 一.编译一个简单的APK LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) # Build all java files in the java subdirec

Android混淆编译时,用到gson-2.2.2.jar进行反射解析json数据时,报ClassCastException错误

在我的代码中,我使用方法是: public synchronized <T> T parseJson(String json, Class<T> classOfT) throws Exception{ T target = null; Gson gson = new Gson(); target = gson.fromJson(json, classOfT); return target; } 之后在我的Activity中使用方式是: String addModel = JsonP

Android.mk编译的写法

一.Android 的简介: 1.Android.mk文件首先需要指定LOCAL_PATH变量,用于查找源文件.由于一般情况下Android.mk和需要编译的源文件在同一目录下,所以定义成如下形式: LOCAL_PATH:=$(call my-dir) 上面的语句的意思是将LOCAL_PATH变量定义成本文件所在目录路径. 2. Android.mk中可以定义多个编译模块,每个编译模块都是以include $(CLEAR_VARS)开始,以include $(BUILD_XXX)结束. incl

Android之JNI:Android Studio使用Android.mk编译C/C++源码

1.生成.h头文件,配置.c文件(可查看Android之JNI:Android Studio使用Gradle编译C/C++源码) 2.编写Android.mk //Android.mk简介参考链接:http://blog.sina.com.cn/s/blog_602f8770010148ce.htmlLOCAL_PATH:= $(call my-dir) //Android.mk 文件首先必须定义LOCAL_PATH变量,以便用于在开发树中查找源文件.宏函数'my-dir'由编译系统提供,用于返

Android NDK编译本地文件以及引用第三方so文件

LOCAL_PATH := $(call my-dir)include $(CLEAR_VARS)LOCAL_LDLIBS :=-llogLOCAL_MODULE := DeviceAPILOCAL_SRC_FILES := DeviceAPI.c \ include $(BUILD_SHARED_LIBRARY) include $(CLEAR_VARS)LOCAL_MODULE := libbarcodereaderLOCAL_SRC_FILES := libbarcodereader.so

android.mk android源码编译

http://www.cnblogs.com/chenbin7/archive/2013/01/05/2846863.html Android.mk简单分析 2013-01-05 22:51 by ...平..淡..., 884 阅读, 0 评论, 收藏, 编辑 LOCAL_PATH:= $(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE_TAGS := optional LOCAL_SRC_FILES := $(call all-java-fil

Android NDK开发指南---Application.mk文件和android.mk文件

https://android.googlesource.com/platform/development/+/donut-release/ndk/docs/OVERVIEW.TXT https://android.googlesource.com/platform/ndk/+/4e159d95ebf23b5f72bb707b0cb1518ef96b3d03/docs/ANDROID-MK.TXT https://android.googlesource.com/platform/ndk/+/4

【转】Android源代码编译命令m/mm/mmm/make分析--不错

原文网址:http://blog.csdn.net/luoshengyang/article/details/19023609 在前文中,我们分析了Android编译环境的初始化过程.Android编译环境初始化完成后,我们就可以用m/mm/mmm/make命令编译源代码了.当然,这要求每一个模块都有一个Android.mk文件.Android.mk实际上是一个Makefile脚本,用来描述模块编译信息.Android编译系统通过整合Android.mk文件完成编译过程.本文就对Android源

Android.mk简介

转载:http://blog.csdn.net/sanchuyayun/article/details/8242901 Android.mk文件是GNU Makefile的一小部分,它用来对Android程序进行编译. 因为所有的编译文件都在同一个 GNU MAKE 执行环境中进行执行,而Android.mk中所有的变量都是全局的.因此,您应尽量少声明变量,不要认为某些变量在解析过程中不会被定义. 一个Android.mk文件可以编译多个模块,每个模块属下列类型之一: 1)APK程序 一般的An