how can I use annotationProcessor in android.mk - android

I just want to use bufferknife and drag2 in my system app, I have built my app with the command mm.
I have tried every possible method I could find, but failed! I've only found the below Android.mk by Googling:
# Copyright (C) 2015 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 c
opy 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.
LOCAL_PATH := $(call my-dir)
# Include definitions of DAGGER2_PROCESSOR_CLASSES/LIBRARIES
include external/dagger2/dagger2_annotation_processor.mk
# build caliper host jar
# ============================================================
include $(CLEAR_VARS)
LOCAL_MODULE := caliper-host
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
LOCAL_SRC_FILES := $(call all-java-files-under, caliper/src/main/java/)
LOCAL_JAVA_RESOURCE_DIRS := caliper/src/main/resources
LOCAL_IS_HOST_MODULE := true
LOCAL_STATIC_JAVA_LIBRARIES := \
apache-commons-math-host \
caliper-gson-host \
caliper-java-allocation-instrumenter-host \
caliper-jersey-client-host \
caliper-jersey-core-host \
caliper-joda-time-host \
caliper-jsr311-api-host \
dagger2-host \
dagger2-inject-host \
guavalib
# Use Dagger2 annotation processor
PROCESSOR_LIBRARIES := $(DAGGER2_PROCESSOR_LIBRARIES)
PROCESSOR_CLASSES := $(DAGGER2_PROCESSOR_CLASSES)
include external/dagger2/java_annotation_processors.mk
include $(BUILD_HOST_JAVA_LIBRARY)
# Remember the location of the generated files, this is needed for when
# building for target
caliper_host_generated_sources_dir := $(local-generated-sources-dir)/annotation_processor_output
# build caliper target api jar
# ============================================================
# This contains just those classes needed for benchmarks to compile.
include $(CLEAR_VARS)
LOCAL_MODULE := caliper-api-target
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
LOCAL_SRC_FILES := \
caliper/src/main/java/com/google/caliper/AfterExperiment.java \
caliper/src/main/java/com/google/caliper/BeforeExperiment.java \
caliper/src/main/java/com/google/caliper/Param.java \
caliper/src/main/java/com/google/caliper/All.java \
caliper/src/main/java/com/google/caliper/Benchmark.java
include $(BUILD_JAVA_LIBRARY)
# build caliper tests
# ============================================================
# vogar --expectations $ANDROID_BUILD_TOP/external/caliper/expec`enter code here`tations/knownfailures.txt \
--test-only \
--classpath $ANDROID_BUILD_TOP/out/host/common/obj/JAVA_LIBRARIES/caliper-tests_intermediates/javalib.jar \
com.google.caliper
include $(CLEAR_VARS)
LOCAL_MODULE := caliper-tests
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
LOCAL_SRC_FILES := $(call all-java-files-under, caliper/src/test/java/)
LOCAL_JAVA_RESOURCE_DIRS := caliper/src/test/resources
LOCAL_IS_HOST_MODULE := true
LOCAL_STATIC_JAVA_LIBRARIES := \
caliper-host \
junit \
mockito-host
# Use Dagger2 annotation processor
PROCESSOR_LIBRARIES := $(DAGGER2_PROCESSOR_LIBRARIES)
PROCESSOR_CLASSES := $(DAGGER2_PROCESSOR_CLASSES)
include external/dagger2/java_annotation_processors.mk
include $(BUILD_HOST_JAVA_LIBRARY)
# build caliper examples
# ============================================================
include $(CLEAR_VARS)
LOCAL_MODULE := caliper-examples
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
LOCAL_SRC_FILES := $(call all-java-files-under, examples/src/main/java/)
LOCAL_IS_HOST_MODULE := true
LOCAL_STATIC_JAVA_LIBRARIES := \
caliper-host \
junit \
mockito-host
include $(BUILD_HOST_JAVA_LIBRARY)
# Build host dependencies.
# ============================================================
include $(CLEAR_VARS)
LOCAL_PREBUILT_JAVA_LIBRARIES := \
caliper-gson-host:lib/gson-2.2.2$(COMMON_JAVA_PACKAGE_SUFFIX) \
caliper-java-allocation-instrumenter-host:lib/java-allocation-instrumenter-2.0$(COMMON_JAVA_PACKAGE_SUFFIX) \
caliper-jersey-client-host:lib/jersey-client-1.11$(COMMON_JAVA_PACKAGE_SUFFIX) \
caliper-jersey-core-host:lib/jersey-core-1.11$(COMMON_JAVA_PACKAGE_SUFFIX) \
caliper-joda-time-host:lib/joda-time-2.1$(COMMON_JAVA_PACKAGE_SUFFIX) \
caliper-jsr311-api-host:lib/jsr311-api-1.1.1$(COMMON_JAVA_PACKAGE_SUFFIX)
include $(BUILD_HOST_PREBUILT)

I done a sample aosp dagger app using below android.mk.
Just try and let me know the result.
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res \
frameworks/support/v7/appcompat/res \
frameworks/support/design/res
LOCAL_PACKAGE_NAME := DaggerSample
LOCAL_STATIC_JAVA_LIBRARIES += android-support-v4
LOCAL_STATIC_JAVA_LIBRARIES += android-support-v7-appcompat
LOCAL_STATIC_JAVA_LIBRARIES += android-support-v7-gridlayout
LOCAL_STATIC_JAVA_LIBRARIES += android-support-v13
LOCAL_STATIC_JAVA_LIBRARIES += ds-dagger2-target
LOCAL_STATIC_JAVA_LIBRARIES += ds-guava-target
LOCAL_STATIC_JAVA_LIBRARIES += ds-javax-annotation-api-target
LOCAL_STATIC_JAVA_LIBRARIES += jsr305
LOCAL_STATIC_JAVA_LIBRARIES += ds-javax-inject-target
LOCAL_JAVA_LIBRARIES := \
ds-auto-value \
# Libraries needed by the compiler (JACK) to generate code.
PROCESSOR_LIBRARIES_TARGET := \
ds-auto-value \
ds-dagger2 \
ds-dagger2-compiler \
ds-dagger2-producers \
ds-guava \
ds-javax-annotation-api \
ds-javax-inject \
# Resolve the jar paths.
PROCESSOR_JARS := $(call java-lib-deps, $(PROCESSOR_LIBRARIES_TARGET))
# Necessary for annotation processors to work correctly.
LOCAL_ADDITIONAL_DEPENDENCIES += $(PROCESSOR_JARS)
LOCAL_JACK_FLAGS += --processorpath $(call normalize-path-list,$(PROCESSOR_JARS))
LOCAL_JAVACFLAGS += -processorpath $(call normalize-path-list,$(PROCESSOR_JARS))
LOCAL_CERTIFICATE := platform
LOCAL_MODULE_TAGS := optional
LOCAL_PRIVILEGED_MODULE := true
LOCAL_USE_AAPT2 := true
LOCAL_PROGUARD_ENABLED := disabled
LOCAL_DEX_PREOPT := false
LOCAL_AAPT_FLAGS := --auto-add-overlay
LOCAL_AAPT_FLAGS += --extra-packages android.support.v7.appcompat:android.support.v7.gridlayout
include $(BUILD_PACKAGE)
# Create references to prebuilt libraries.
include $(CLEAR_VARS)
LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES := \
ds-auto-value:../../../prebuilts/tools/common/m2/repository/com/google/auto/value/auto-value/1.3/auto-value-1.3$(COMMON_JAVA_PACKAGE_SUFFIX) \
ds-dagger2-compiler:../../../prebuilts/tools/common/m2/repository/com/google/dagger/dagger-compiler/2.7/dagger-compiler-2.7$(COMMON_JAVA_PACKAGE_SUFFIX) \
ds-dagger2:../../../prebuilts/tools/common/m2/repository/com/google/dagger/dagger/2.7/dagger-2.7$(COMMON_JAVA_PACKAGE_SUFFIX) \
ds-dagger2-producers:../../../prebuilts/tools/common/m2/repository/com/google/dagger/dagger-producers/2.7/dagger-producers-2.7$(COMMON_JAVA_PACKAGE_SUFFIX) \
ds-guava:../../../prebuilts/tools/common/m2/repository/com/google/guava/guava/20.0/guava-20.0$(COMMON_JAVA_PACKAGE_SUFFIX) \
ds-javax-annotation-api:../../../prebuilts/tools/common/m2/repository/javax/annotation/javax.annotation-api/1.2/javax.annotation-api-1.2$(COMMON_JAVA_PACKAGE_SUFFIX) \
ds-javax-inject:../../../prebuilts/tools/common/m2/repository/javax/inject/javax.inject/1/javax.inject-1$(COMMON_JAVA_PACKAGE_SUFFIX)
include $(BUILD_MULTI_PREBUILT)
include $(CLEAR_VARS)
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
LOCAL_MODULE := ds-guava-target
LOCAL_SDK_VERSION := current
LOCAL_SRC_FILES := ../../../prebuilts/tools/common/m2/repository/com/google/guava/guava/20.0/guava-20.0$(COMMON_JAVA_PACKAGE_SUFFIX)
LOCAL_UNINSTALLABLE_MODULE := true
include $(BUILD_PREBUILT)
include $(CLEAR_VARS)
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
LOCAL_MODULE := ds-dagger2-target
LOCAL_SDK_VERSION := current
LOCAL_SRC_FILES := ../../../prebuilts/tools/common/m2/repository/com/google/dagger/dagger/2.7/dagger-2.7$(COMMON_JAVA_PACKAGE_SUFFIX)
LOCAL_UNINSTALLABLE_MODULE := true
include $(BUILD_PREBUILT)
include $(CLEAR_VARS)
include $(CLEAR_VARS)
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
LOCAL_MODULE := ds-javax-annotation-api-target
LOCAL_SDK_VERSION := current
LOCAL_SRC_FILES := ../../../prebuilts/tools/common/m2/repository/javax/annotation/javax.annotation-api/1.2/javax.annotation-api-1.2$(COMMON_JAVA_PACKAGE_SUFFIX)
LOCAL_UNINSTALLABLE_MODULE := true
include $(BUILD_PREBUILT)
include $(CLEAR_VARS)
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
LOCAL_MODULE := ds-javax-inject-target
LOCAL_SDK_VERSION := current
LOCAL_SRC_FILES := ../../../prebuilts/tools/common/m2/repository/javax/inject/javax.inject/1/javax.inject-1$(COMMON_JAVA_PACKAGE_SUFFIX)
LOCAL_UNINSTALLABLE_MODULE := true
include $(BUILD_PREBUILT)

Related

How to import a .so Library in Android.mk when i build APK

I have this problem: I have to build my app using the Android.mk file and I have to insert the library "libcom_google_ase_Exec.so" inside the final apk, but I can't do it. What I get is an APK that doesn't contain the library and therefore the app doesn't work.
The code for the Android.mk I'm currently using is:
#ifneq ($(TARGET_BUILD_PDK), true)
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := com_google_ase_Exec
LOCAL_SRC_FILES := app/src/main/jniLibs/armeabi/libcom_google_ase_Exec.so
include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_PACKAGE_NAME := Sshd
LOCAL_PRIVATE_PLATFORM_APIS := true
LOCAL_MODULE_TAGS := samples
LOCAL_USE_AAPT2 := true
LOCAL_SRC_FILES := $(call all-java-files-under, app/src/main/java)
LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/app/src/main/res/
LOCAL_MANIFEST_FILE := app/src/main/AndroidManifest.xml
# LOCAL_ASSETS_DIR := $(LOCAL_PATH)/assets
LOCAL_STATIC_ANDROID_LIBRARIES += \
android-support-v13 \
android-support-v7-cardview \
android-support-v7-recyclerview \
android-support-annotations
LOCAL_STATIC_JAVA_LIBRARIES := \
libsshd-core \
libsshd-common \
libsshd-scp \
libsshd-sftp \
libslf4j \
libbcpkix \
libbcprov
LOCAL_CERTIFICATE := platform
LOCAL_PRIVILEGED_MODULE := true
LOCAL_PROGUARD_ENABLED := disabled
LOCAL_DEX_PREOPT := false
LOCAL_SHARED_LIBRARIES := libcom_google_ase_Exec
#LOCAL_PREBUILTS := com_google_ase_Exec
include $(BUILD_PACKAGE)
include $(CLEAR_VARS)
LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES := \
libsshd-core:app/libs/sshd-core-2.8.0.jar \
libsshd-common:app/libs/sshd-common-2.8.0.jar \
libsshd-scp:app/libs/sshd-scp-2.8.0.jar \
libsshd-sftp:app/libs/sshd-sftp-2.8.0.jar \
libslf4j:app/libs/slf4j-api-1.7.35.jar \
libbcpkix:app/libs/bcpkix-jdk15on-1.70.jar \
libbcprov:app/libs/bcprov-jdk15on-1.70.jar
include $(BUILD_MULTI_PREBUILT)
#include $(call all-makefiles-under, $(LOCAL_PATH))
#endif
The folder structure within my project is as follows:
In the root i have:
--> /app and Android.mk
In the app folder i have:
--> app/src/main/jniLibs/armeabi/libcom_google_ase_Exec.so
How can i change the Android.mk file to import the .so library in the final APK?
#ifneq ($(TARGET_BUILD_PDK), true)
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_PACKAGE_NAME := Sshd
LOCAL_PRIVATE_PLATFORM_APIS := true
LOCAL_MODULE_TAGS := samples
LOCAL_USE_AAPT2 := true
LOCAL_SRC_FILES := $(call all-java-files-under, app/src/main/java)
LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/app/src/main/res/
LOCAL_MANIFEST_FILE := app/src/main/AndroidManifest.xml
# LOCAL_ASSETS_DIR := $(LOCAL_PATH)/assets
LOCAL_STATIC_ANDROID_LIBRARIES += \
android-support-v13 \
android-support-v7-cardview \
android-support-v7-recyclerview \
android-support-annotations
LOCAL_STATIC_JAVA_LIBRARIES := \
libsshd-core \
libsshd-common \
libsshd-scp \
libsshd-sftp \
libslf4j \
libbcpkix \
libbcprov
LOCAL_JNI_SHARED_LIBRARIES := libcom_google_ase_Exec
#LOCAL_MULTILIB = 32
LOCAL_CERTIFICATE := platform
LOCAL_PRIVILEGED_MODULE := true
LOCAL_PROGUARD_ENABLED := disabled
#LOCAL_UNINSTALLABLE_MODULE := true
#LOCAL_DEX_PREOPT := false
include $(BUILD_PACKAGE)
include $(CLEAR_VARS)
LOCAL_CERTIFICATE := platform
LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES := \
libsshd-core:app/libs/sshd-core-2.8.0.jar \
libsshd-common:app/libs/sshd-common-2.8.0.jar \
libsshd-scp:app/libs/sshd-scp-2.8.0.jar \
libsshd-sftp:app/libs/sshd-sftp-2.8.0.jar \
libslf4j:app/libs/slf4j-api-1.7.35.jar \
libbcpkix:app/libs/bcpkix-jdk15on-1.70.jar \
libbcprov:app/libs/bcprov-jdk15on-1.70.jar
include $(BUILD_MULTI_PREBUILT)
include $(CLEAR_VARS)
LOCAL_MODULE := libcom_google_ase_Exec
LOCAL_MODULE_TAGS := samples
LOCAL_CERTIFICATE := platform
LOCAL_SRC_FILES := app/src/main/jniLibs/armeabi/libcom_google_ase_Exec.so
#LOCAL_MULTILIB = 32
LOCAL_MODULE_CLASS := SHARED_LIBRARIES
LOCAL_MODULE_SUFFIX = .so
include $(BUILD_PREBUILT)
#include $(call all-makefiles-under, $(LOCAL_PATH))
#endif
I solved in this way, i build a 64bit version.
If u need a 32bit version u can uncomment all LOCAL_MULTILIB = 32.

WorkManager in AOSP

Trying to use WorkManager in my SystemApp. I haven't been able to integrate it.
Android.mk :
include $(CLEAR_VARS)
LOCAL_PACKAGE_NAME := MySystemApp
LOCAL_CERTIFICATE := platform
LOCAL_PRIVILEGED_MODULE := true
LOCAL_MODULE_TAGS := optional
LOCAL_JNI_SHARED_LIBRARIES := libloguploaderclient
LOCAL_SRC_FILES := $(call all-java-files-under, android/src)
LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/android/res
LOCAL_STATIC_ANDROID_LIBRARIES := \
androidx.core_core \
androidx.annotation_annotation \
androidx.work_work # This line doesn't work
LOCAL_PROGUARD_FLAG_FILES := android/proguard.cfg
LOCAL_PROGUARD_ENABLED := disabled
LOCAL_SDK_VERSION := current
ifeq ($(shell test $(PLATFORM_SDK_VERSION) -ge 28 && echo OK),OK)
# Build as a vendor module
LOCAL_PROPRIETARY_MODULE := true
endif
# Build as an Android app
include $(BUILD_PACKAGE)
The below part of the mk file doesn't work and giving bunch of compile error:
LOCAL_STATIC_ANDROID_LIBRARIES := \
androidx.core_core \
androidx.annotation_annotation \
androidx.work_work # This line doesn't work
So, how can I use WorkManager in AOSP?

How can I build the PackageInstaller source code?

I've cloned packageInstaller source code from PackageInstaller Source code. The project needs NDK to build but has no Application.mk file. The android.mk file contains these codes:
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_USE_AAPT2 := true
LOCAL_MODULE_TAGS := optional
LOCAL_SRC_FILES := \
$(call all-java-files-under, src)
LOCAL_STATIC_ANDROID_LIBRARIES += \
android-support-v4 \
android-support-annotations \
android-support-v7-recyclerview \
android-support-v7-preference \
android-support-v7-appcompat \
android-support-v14-preference \
android-support-v17-preference-leanback \
android-support-v17-leanback \
SettingsLib
LOCAL_STATIC_JAVA_LIBRARIES := \
xz-java
LOCAL_PACKAGE_NAME := PackageInstaller
LOCAL_CERTIFICATE := platform
LOCAL_PRIVILEGED_MODULE := true
LOCAL_PROGUARD_FLAG_FILES := proguard.flags
# Comment for now unitl all private API dependencies are removed
# LOCAL_SDK_VERSION := system_current
include $(BUILD_PACKAGE)
ifeq (PackageInstaller,$(LOCAL_PACKAGE_NAME))
# Use the following include to make our test apk.
ifeq (,$(ONE_SHOT_MAKEFILE))
include $(call all-makefiles-under,$(LOCAL_PATH))
endif
endif
I had some trouble to build this project, since it has no application.mk files. Now I have two major problem with this project:
How can I add dependencies which are mentioned in the android.mk file?
How can i build the entire project successfully?

While building the AOSP build tree, LOCAL_MODULE not defined error is occures

While building the AOSP (Oreo)source tree, The following error occurs
build/core/dynamic_binary.mk:17: error: packages/apps/TerminalTest/jni:
LOCAL_MODULE not defined before call to local-intermediates-dir.
18:25:16 ckati failed with: exit status 1
#### failed to build some targets (26 seconds) ####
Application Source tree
jni
Android.mk
src
res
Android.mk
Main Android.mk
LOCAL_PATH:= $(call my-dir)
include $(call all-subdir-makefiles)
include $(CLEAR_VARS)
LOCAL_PACKAGE_NAME := TerminalTest
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE := libjni_terminal
LOCAL_SRC_FILES := $(call all-subdir-java-files)
LOCAL_STATIC_JAVA_LIBRARIES := android-support-v4
LOCAL_JNI_SHARED_LIBRARIES := libjni_terminalTest
# TODO: enable proguard once development has settled down
#LOCAL_PROGUARD_FLAG_FILES := proguard.flags
LOCAL_PROGUARD_ENABLED := disabled
include $(BUILD_PACKAGE)
jni/Android.mk
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_SRC_FILES := \
jni_init.cpp \
com_android_terminal_Terminal.cpp \
LOCAL_C_INCLUDES += \
external/libvterm/include \
libcore/include \
frameworks/base/include
LOCAL_SHARED_LIBRARIES := \
libandroidfw \
libandroid_runtime \
liblog \
libnativehelper \
libutils
LOCAL_STATIC_LIBRARIES := \
libvterm
LOCAL_CFLAGS := \
-Wno-unused-parameter \
LOCAL_MODULE := libjni_terminal
LOCAL_MODULE_TAGS := optional
include $(BUILD_SHARED_LIBRARY)
Any help will appreciate
If you use LOCAL_MODULE := libjni_terminal in any other project this error will happen.
When using the same LOCAL_MODULE name in different places lead to problems while creating and accessing intermediate files.

Include aar in android Makefile project

I'm trying to build an Android app through makefile (the app works perfectly when build by Android Studio).
I'm having problems with an .aar module that is used. the make completes successfully, but the .apk size is ridiculously small (500kb instead of 80mb).
The .aar has multiple .so files in ./libs, as well as ./assets, but both seem not to be included.
Android.mk:
LOCAL_SHARED_LIBRARIES := libnativelib
LOCAL_STATIC_JAVA_LIBRARIES:= aarmodulename
...
...
include $(BUILD_PACKAGE)
include $(CLEAR_VARS)
LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES:=aarmodulename:libs/aarmodulename.aar
include $(BUILD_MULTI_PREBUILT)
I've also tried forcing the .so files to be packaged, but I dpn't even know if this is the proper way to do so:
include $(CLEAR_VARS)
LOCAL_MODULE := libnativelib
LOCAL_SRC_FILES := libs/so/libnativelib.so
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_SUFFIX := .so
LOCAL_MODULE_CLASS := SHARED_LIBRARIES
include $(BUILD_PREBUILT)
Why don't the *.so files and the aar's assets get packaged? How do I fix it?
Same problem has been meetted, after read the static_java_library.mk in AOSP, The answer is basically found.
To resolve this problem, you should define LOCAL_USE_AAPT2 := true in your project Android.mk file.
The following is a part of the code in static_java_library.mk:
# Hack to build static Java library with Android resource
# See bug 5714516
all_resources :=
need_compile_res :=
# A static Java library needs to explicily set LOCAL_RESOURCE_DIR.
ifdef LOCAL_RESOURCE_DIR
need_compile_res := true
LOCAL_RESOURCE_DIR := $(foreach d,$(LOCAL_RESOURCE_DIR),$(call clean-path,$(d)))
endif
ifdef LOCAL_USE_AAPT2
ifneq ($(LOCAL_STATIC_ANDROID_LIBRARIES),)
need_compile_res := true
endif
endif
ifeq ($(need_compile_res),true)
all_resources := $(strip \
$(foreach dir, $(LOCAL_RESOURCE_DIR), \
$(addprefix $(dir)/, \
$(patsubst res/%,%, \
$(call find-subdir-assets,$(dir)) \
) \
) \
))
Follow is a sample:
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE_TAGS := optional
ifeq ($(TARGET_BUILD_APPS),)
# Use AAPT2 only when TARGET_BUILD_APPS is empty because AAPT2 is not compatible with the current
# setup of prebuilt support libs used in unbundled builds. b/29836407
LOCAL_USE_AAPT2 := true
endif
# SRC files
LOCAL_SRC_FILES := \
$(call all-java-files-under, src)
LOCAL_RESOURCE_DIR := \
res
# JAR
LOCAL_STATIC_JAVA_LIBRARIES := \
ifdef LOCAL_USE_AAPT2
LOCAL_SHARED_ANDROID_LIBRARIES := \
android-support-annotations \
android-support-compat \
android-support-core-ui \
android-support-v7-appcompat \
android-support-v7-recyclerview
else
LOCAL_AAPT_FLAGS := --auto-add-overlay \
--extra-packages android.support.compat \
--extra-packages android.support.v7.appcompat \
--extra-packages android.support.v7.recyclerview
LOCAL_RESOURCE_DIR += \
frameworks/support/compat/res \
frameworks/support/v7/appcompat/res \
frameworks/support/v7/recyclerview/res
LOCAL_JAVA_LIBRARIES := \
android-support-annotations \
android-support-compat \
android-support-core-ui \
android-support-v7-appcompat \
android-support-v7-recyclerview
# OR define
LOCAL_STATIC_ANDROID_LIBRARIES := \
endif
LOCAL_MANIFEST_FILE := main/AndroidManifest.xml
LOCAL_PACKAGE_NAME := PACKAGE_NAME
LOCAL_CERTIFICATE := platform
LOCAL_PRIVILEGED_MODULE := true
LOCAL_PROGUARD_FLAG_FILES := proguard.flags
# Comment for now unitl all private API dependencies are removed
# LOCAL_SDK_VERSION := system_current
include $(BUILD_PACKAGE)

Categories

Resources