1.编译apk文件至system/app目录
#指定当前目录
LOCAL_PATH := $(call my-dir)
#引入编译变量
include $(CLEAR_VARS)
#编译出来的模块名
LOCAL_MODULE := ESFileExplore
#编译选项便是在何种情况下编译
LOCAL_MODULE_TAGS := optional
#指定编译之后放置的位置
LOCAL_MODULE_CLASS := APPS
LOCAL_MODULE_SUFFIX := $(COMMON_ANDROID_PACKAGE_SUFFIX)
LOCAL_SRC_FILES := $(LOCAL_MODULE).apk
#签名文件
LOCAL_CERTIFICATE := platform
#引入编译成可执行文件的规则
include $(BUILD_PREBUILT)
apk文件和mk文件在同级目录
LOCAL_PATH := $(call my-dir) #指定当前目录
include $(CLEAR_VARS) #引入编译变量
LOCAL_MODULE := hello #编译出来的模块名
LOCAL_MODULE_TAGS := optional #编译选项便是在何种情况下编译
LOCAL_SRC_FILES := hello.c #源文件(可以指定多个)
LOCAL_MODULE_CLASS := EXECUTABLES #指定编译之后放置的位置
include $(BUILD_EXECUTABLE) #引入编译成可执行文件的规则
LOCAL_PACKAGE_NAME #指定APP应用名称
LOCAL_PRIVATE_PLATFORM_APIS := true #设置后,会使用sdk的hide的api來编译
LOCAL_USE_AAPT2 := true #aapt 是编译和打包资源的工具。而aapt2是在aapt上做了优化
LOCAL_JNI_SHARED_LIBRARIES := libbluetooth_jni #声明要使用到的共享 JNI 库的名称
LOCAL_JAVA_LIBRARIES := javax.obex telephony-common services.net #指定依赖的共享java类库,这个是编译时依赖,最终不会打包
LOCAL_STATIC_JAVA_LIBRARIES := \
com.android.vcard \
bluetooth.cc\
services.net \
libprotobuf-java-lite \ #指定依赖的静态java类库,最终会打包到apk里面。引用多个的时候,可以像上面那样写。
LOCAL_STATIC_ANDROID_LIBRARIES := android-support-v4 #声明要调用 android 的包,这里是v4包
LOCAL_REQUIRED_MODULES := libbluetooth #指定依赖的模块。一旦本模块被安装,通过此变量指定的模块也将被安装
LOCAL_PROGUARD_ENABLED := disabled #混淆配置,默认为full obfuscation,全代码混淆,disabled不开启
include $(BUILD_PACKAGE) #编译成APK 文件
include $(BUILD_STATIC_JAVA_LIBRARY) #生成静态JAVA库
2.编译含有so文件的apk
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := SXInput
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_CLASS := APPS
LOCAL_MODULE_SUFFIX := $(COMMON_ANDROID_PACKAGE_SUFFIX)
LOCAL_SRC_FILES := $(LOCAL_MODULE).apk
LOCAL_CERTIFICATE := PRESIGNED
# get *.so
LOCAL_MULTILIB := 32
JNI_LIBS :=
app_unzip_files :=$(shell rm -rf $(LOCAL_PATH)/lib )
app_unzip_files :=$(shell unzip -o $(LOCAL_PATH)/$(LOCAL_MODULE).apk "*lib/*" -d $(LOCAL_PATH)/)
$(foreach FILE,$(shell find $(LOCAL_PATH)/lib/armeabi-v7a/ -name *.so), $(eval JNI_LIBS += $(FILE)))
LOCAL_PREBUILT_JNI_LIBS := $(subst $(LOCAL_PATH)/,,$(JNI_LIBS))
include $(BUILD_PREBUILT)