一、预装应用Android.mk文件常见用法
1、第三方apk无源码
LOCAL_PATH:=$(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE:=Demo//(应用名称)
LOCAL_MODULE_TAGS:=optional
LOCAL_MODULE_CLASS:=APPS
LOCAL_SRC_FILES:=$(LOCAL_MODULE).apk
LOCAL_MODULE_SUFFIX:=$(COMMON_ANDROID_PACKAGE_SUFFIX)
LOCAL_DEX_PREOPT = false
LOCAL_CERTIFICATE:=PRESIGNED
include $(BUILD_PREBUILT)
2、第三方apk无源码添加自定义编译出来的路径
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := Demo//(应用名称)
LOCAL_MODULE_TAGS := optional
LOCAL_SRC_FILES := $(LOCAL_MODULE).apk
LOCAL_MODULE_CLASS := APPS
LOCAL_MODULE_SUFFIX := $(COMMON_ANDROID_PACKAGE_SUFFIX)
LOCAL_CERTIFICATE := PRESIGNED
LOCAL_MODULE_PATH := $(TARGET_OUT)/vendor/operator/app
include $(BUILD_PREBUILT)
3、编译出来apk带so库64位
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE := Demo
LOCAL_SRC_FILES := Demo.apk
LOCAL_MODULE_CLASS := APPS
LOCAL_MULTILIB := 64
LOCAL_PREBUILT_JNI_LIBS := \
@lib/arm64-v8a/*.so
LOCAL_MODULE_SUFFIX := $(COMMON_ANDROID_PACKAGE_SUFFIX)
LOCAL_CERTIFICATE := platform
LOCAL_DEX_PREOPT = false
#LOCAL_CERTIFICATE := PRESIGNED
include $(BUILD_PREBUILT)
4、编译出来apk带so库64位
LOCAL_PATH := $(call my-dir)
ifeq ($(strip $(PRODUCT_HAVE_TUFEIFEI)),ON)
include $(CLEAR_VARS)
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE := Demo
LOCAL_SRC_FILES := Demo.apk
LOCAL_MULTILIB := 32
LOCAL_PREBUILT_JNI_LIBS := \
@lib/armeabi-v7a/*.so
LOCAL_MODULE_CLASS := APPS
LOCAL_MODULE_SUFFIX := $(COMMON_ANDROID_PACKAGE_SUFFIX)
LOCAL_CERTIFICATE := platform
#LOCAL_DEX_PREOPT = false
include $(BUILD_PREBUILT)
endif
5、带eclipse项目工程源码mk文件
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_DEX_PREOPT = false
LOCAL_MODULE_TAGS := optional
LOCAL_CERTIFICATE := platform
LOCAL_PACKAGE_NAME := Demo
LOCAL_MULTILIB :=both
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_JAVA_LIBRARIES := bouncycastle conscrypt telephony-common \
com.abc.android
LOCAL_STATIC_JAVA_LIBRARIES := \
android-support-v4 \
android-support-v7-appcompat \
android-support-v7-cardview \
android-support-v7-recyclerview
LOCAL_RESOURCE_DIR := \
$(LOCAL_PATH)/res \
frameworks/support/v7/appcompat/res \
frameworks/support/v7/cardview/res \
frameworks/support/v7/recyclerview/res
LOCAL_AAPT_FLAGS := \
--auto-add-overlay \
--extra-packages android.support.v7.appcompat \
--extra-packages android.support.v7.cardview \
--extra-packages android.support.v7.recyclerview
include $(BUILD_PACKAGE)
include $(call all-makefiles-under,$(LOCAL_PATH))
6、Android Studio项目在源码中编译Launcher中mk文件写法
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE_TAGS := optional
LOCAL_CERTIFICATE := platform
LOCAL_PACKAGE_NAME := Demo
LOCAL_PRIVILEGED_MODULE := true
#LOCAL_DEX_PREOPT = false
LOCAL_MULTILIB :=both
LOCAL_OVERRIDES_PACKAGES := \
Home \
Launcher2
src_dir = app/src/main/java
res_dir = app/src/main/res
LOCAL_MANIFEST_FILE := app/src/main/AndroidManifest.xml
LOCAL_SRC_FILES := $(call all-java-files-under, $(src_dir))
LOCAL_JAVA_LIBRARIES := bouncycastle conscrypt telephony-common \
com.abc.android
LOCAL_STATIC_JAVA_LIBRARIES := \
android-support-v4 \
android-support-v7-appcompat \
android-support-v7-cardview \
android-support-v7-recyclerview \
android-support-v7-palette
LOCAL_RESOURCE_DIR := \
$(LOCAL_PATH)/$(res_dir) \
frameworks/support/v7/appcompat/res \
frameworks/support/v7/cardview/res \
frameworks/support/v7/recyclerview/res
LOCAL_AAPT_FLAGS := \
--auto-add-overlay \
--extra-packages android.support.v7.appcompat \
--extra-packages android.support.v7.cardview \
--extra-packages android.support.v7.recyclerview
include $(BUILD_PACKAGE)
include $(call all-makefiles-under,$(LOCAL_PATH))