Build support libs with AAPT2

Use AAPT2 to build the framework support libraries. Apps built with AAPT2 can more efficiently
link against these libraries by specifying their module name in LOCAL_STATIC_ANDROID_LIBRARIES.

Ex:

LOCAL_STATIC_ANDROID_LIBRARIES := android-support-v7-appcompat android-support-v4

Apps built with AAPT2 do not need to specify --auto-add-overlay or --extra-packages, as these
are automatically added as needed by the build system.

This change will not affect any apps that currently depend on the support libraries.
This is because they import the resources directly.

We use LOCAL_JAR_EXCLUDE_FILES := none only to support javac when building javadoc.
Jack builds are correct because the build system passes in the latest generated R.java
ahead of any previous ones packaged in classes.jack. This means we can dynamically reference
a support lib module, correctly seeing non-final R.java. Then at app package time, we only
include the final R.java generated by the AAPT2 packaging step.

Bug:25958912
Change-Id: I6577a91e4d428dd29fecaa86a26be43d4da8310c
diff --git a/v7/palette/Android.mk b/v7/palette/Android.mk
index 0c4cb05..814ef24 100644
--- a/v7/palette/Android.mk
+++ b/v7/palette/Android.mk
@@ -15,13 +15,24 @@
 LOCAL_PATH := $(call my-dir)
 
 # Here is the final static library that apps can link against.
+# Applications that use this library must specify
+#
+#   LOCAL_STATIC_ANDROID_LIBRARIES := \
+#       android-support-v7-palette \
+#       android-support-v4
+#
+# in their makefiles to include the resources and their dependencies in their package.
 include $(CLEAR_VARS)
+LOCAL_USE_AAPT2 := true
 LOCAL_MODULE := android-support-v7-palette
 LOCAL_SDK_VERSION := 7
 LOCAL_SRC_FILES := $(call all-java-files-under, src/main)
-LOCAL_MANIFEST_FILE := $(LOCAL_PATH)/src/main/AndroidManifest.xml
-LOCAL_JAVA_LIBRARIES += android-support-v4
+LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res
+LOCAL_MANIFEST_FILE := src/main/AndroidManifest.xml
+LOCAL_SHARED_ANDROID_LIBRARIES += android-support-v4
+LOCAL_JAR_EXCLUDE_FILES := none
 LOCAL_JAVA_LANGUAGE_VERSION := 1.7
+LOCAL_AAPT_FLAGS := --add-javadoc-annotation doconly
 include $(BUILD_STATIC_JAVA_LIBRARY)
 
 # API Check