#
# Copyright (C) 2008 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# 每个Android.mk文件必须以定义LOCAL_PATH为开始。它用于在开发tree中查找源文件。
# my-dir 则由Build System提供。返回包含Android.mk的目录路径。固定写法
LOCAL_PATH := $(call my-dir)
# CLEAR_VARS 变量由Build System提供。并指向一个指定的GNU Makefile,负责清理多余的LOCAL_xxx.
# 这个清理动作是必须的,因为所有的编译控制文件由同一个GNU Make解析和执行,其变量是全局的
# 所以清理后才能避免相互影响 比如LOCAL_MODULE, LOCAL_SRC_FILES, LOCAL_STATIC_LIBRARIES
include $(CLEAR_VARS)
# 定义引用的jar包:名字自定义,后面会针对名字进行路径说明
LOCAL_STATIC_JAVA_LIBRARIES := supportinternal supportannotions
# 定义引用的aar包:名字自定义,后面会针对名字进行路径说明
# aar包内如果有jar包,需要导出引用比如V4包有jar包
LOCAL_STATIC_JAVA_AAR_LIBRARIES := support4
# 定义src文件路径
LOCAL_SRC_FILES := $(call all-subdir-Java-files) $(call all-java-files-under, src) $(call all-renderscript-files-under, src)
# 定义res文件路径
LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res
# 定义打包后名称
LOCAL_PACKAGE_NAME := OpenthosLauncher
# 定义生成的apk使用的key
# platform 表示使用系统的key打包
LOCAL_CERTIFICATE := platform include $(BUILD_PACKAGE) include $(CLEAR_VARS)
# 定义jar包 aar包的路径 :后面跟的是相对Android.mk文件的相对路径
LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES := supportinternal:lib/support-annotations-22.2.1-sources.jar \
supportannmtions:lib/internal_impl-22.2.1.jar \
support4:lib/support-v4-22.2.1.aar \
include $(CLEAR_VARS)
# 因为aar包的存在,这个主要是用于合并AndroidManifest.xml 和res资源文件
LOCAL_AAPT_FLAG := \
--auto-add-overlay \
--extra-package android.support.v4 \
--extra-package com.openthos.launcher.openthoslauncher
# 指明合并后的AndroidManifest.xml的路径 (一般不用指定)
LOCAL_MANIFEST_FILE := $(LOCAL_PATH)/AndroidManifest.xml
# 因引入jar包或aar包,须加上这句
include $(BUILD_MULTI_PREBUILT)
include $(call all-makefiles-under,$(LOCAL_PATH))
Android.mk初识
最新推荐文章于 2024-06-26 00:30:00 发布