Revert "Build support libs with AAPT2"

This reverts commit 66b8608151c5923de3c9877bc03218d83f6b3beb.

Change-Id: I2178c0336bef8386e1f36ff3816b6dbf1e6a64d0
diff --git a/annotations/Android.mk b/annotations/Android.mk
index 200a6ee..df16cdb 100644
--- a/annotations/Android.mk
+++ b/annotations/Android.mk
@@ -15,10 +15,8 @@
 LOCAL_PATH := $(call my-dir)
 
 include $(CLEAR_VARS)
-LOCAL_USE_AAPT2 := true
 LOCAL_MODULE := android-support-annotations
 LOCAL_SDK_VERSION := $(SUPPORT_CURRENT_SDK_VERSION)
 LOCAL_SRC_FILES := $(call all-java-files-under,src)
-LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res
 LOCAL_JAVA_LANGUAGE_VERSION := 1.7
 include $(BUILD_STATIC_JAVA_LIBRARY)
diff --git a/annotations/AndroidManifest.xml b/annotations/AndroidManifest.xml
deleted file mode 100644
index 6f24ecb..0000000
--- a/annotations/AndroidManifest.xml
+++ /dev/null
@@ -1,2 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<manifest package="android.support.annotations" />
diff --git a/design/Android.mk b/design/Android.mk
index 12bfbe3..c4004f5 100644
--- a/design/Android.mk
+++ b/design/Android.mk
@@ -14,23 +14,22 @@
 
 LOCAL_PATH := $(call my-dir)
 
-# Android libraries referenced by this module's resources.
-resource_libs := \
-    android-support-v7-appcompat \
-    android-support-v7-recyclerview
-
 # Build the resources using the latest applicable SDK version.
 # We do this here because the final static library must be compiled with an older
 # SDK version than the resources.  The resources library and the R class that it
 # contains will not be linked into the final static library.
 include $(CLEAR_VARS)
-LOCAL_USE_AAPT2 := true
 LOCAL_MODULE := android-support-design-res
 LOCAL_SDK_VERSION := $(SUPPORT_CURRENT_SDK_VERSION)
 LOCAL_SRC_FILES := $(call all-java-files-under, dummy)
-LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res
-LOCAL_SHARED_ANDROID_LIBRARIES := $(resource_libs)
-LOCAL_AAPT_FLAGS := --no-version-vectors
+LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res \
+    frameworks/support/v7/appcompat/res \
+    frameworks/support/v7/recyclerview/res
+LOCAL_AAPT_FLAGS := \
+    --auto-add-overlay \
+    --extra-packages android.support.v7.appcompat \
+    --extra-packages android.support.v7.recyclerview \
+    --no-version-vectors
 LOCAL_JAR_EXCLUDE_FILES := none
 LOCAL_JAVA_LANGUAGE_VERSION := 1.7
 include $(BUILD_STATIC_JAVA_LIBRARY)
@@ -43,8 +42,7 @@
 LOCAL_MODULE := android-support-design-base
 LOCAL_SDK_VERSION := 7
 LOCAL_SRC_FILES := $(call all-java-files-under, base)
-LOCAL_JAVA_LIBRARIES := \
-    android-support-design-res \
+LOCAL_JAVA_LIBRARIES := android-support-design-res \
     android-support-v4 \
     android-support-v7-appcompat \
     android-support-v7-recyclerview
@@ -59,8 +57,7 @@
 LOCAL_SDK_VERSION := 7
 LOCAL_SRC_FILES := $(call all-java-files-under, eclair-mr1)
 LOCAL_STATIC_JAVA_LIBRARIES := android-support-design-base
-LOCAL_JAVA_LIBRARIES := \
-    android-support-design-res \
+LOCAL_JAVA_LIBRARIES := android-support-design-res \
     android-support-v4 \
     android-support-v7-appcompat \
     android-support-v7-recyclerview
@@ -75,8 +72,7 @@
 LOCAL_SDK_VERSION := 11
 LOCAL_SRC_FILES := $(call all-java-files-under, honeycomb)
 LOCAL_STATIC_JAVA_LIBRARIES := android-support-design-eclair-mr1
-LOCAL_JAVA_LIBRARIES := \
-    android-support-design-res \
+LOCAL_JAVA_LIBRARIES := android-support-design-res \
     android-support-v4 \
     android-support-v7-appcompat \
     android-support-v7-recyclerview
@@ -91,8 +87,7 @@
 LOCAL_SDK_VERSION := 12
 LOCAL_SRC_FILES := $(call all-java-files-under, honeycomb-mr1)
 LOCAL_STATIC_JAVA_LIBRARIES := android-support-design-honeycomb
-LOCAL_JAVA_LIBRARIES := \
-    android-support-design-res \
+LOCAL_JAVA_LIBRARIES := android-support-design-res \
     android-support-v4 \
     android-support-v7-appcompat \
     android-support-v7-recyclerview
@@ -107,8 +102,7 @@
 LOCAL_SDK_VERSION := 14
 LOCAL_SRC_FILES := $(call all-java-files-under, ics)
 LOCAL_STATIC_JAVA_LIBRARIES := android-support-design-honeycomb-mr1
-LOCAL_JAVA_LIBRARIES := \
-    android-support-design-res \
+LOCAL_JAVA_LIBRARIES := android-support-design-res \
     android-support-v4 \
     android-support-v7-appcompat \
     android-support-v7-recyclerview
@@ -123,8 +117,7 @@
 LOCAL_SDK_VERSION := 21
 LOCAL_SRC_FILES := $(call all-java-files-under, lollipop)
 LOCAL_STATIC_JAVA_LIBRARIES := android-support-design-ics
-LOCAL_JAVA_LIBRARIES := \
-    android-support-design-res \
+LOCAL_JAVA_LIBRARIES := android-support-design-res \
     android-support-v4 \
     android-support-v7-appcompat \
     android-support-v7-recyclerview
@@ -134,24 +127,18 @@
 support_module_src_files += $(LOCAL_SRC_FILES)
 
 # Here is the final static library that apps can link against.
-# Applications that use this library must specify
-#
-#   LOCAL_STATIC_ANDROID_LIBRARIES := \
-#       android-support-design \
-#       android-support-v7-appcompat \
-#       android-support-v7-recyclerview \
-#       android-support-v4
-#
-# in their makefiles to include the resources and their dependencies in their package.
+# The R class is automatically excluded from the generated library.
+# Applications that use this library must specify LOCAL_RESOURCE_DIR
+# in their makefiles to include the resources in their package.
 include $(CLEAR_VARS)
-LOCAL_USE_AAPT2 := true
 LOCAL_MODULE := android-support-design
 LOCAL_SDK_VERSION := $(SUPPORT_CURRENT_SDK_VERSION)
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
 LOCAL_STATIC_JAVA_LIBRARIES := android-support-design-lollipop
-LOCAL_STATIC_ANDROID_LIBRARIES := android-support-design-res
-LOCAL_SHARED_ANDROID_LIBRARIES := $(resource_libs) android-support-v4
-LOCAL_JAR_EXCLUDE_FILES := none
+LOCAL_JAVA_LIBRARIES := android-support-design-res \
+    android-support-v4 \
+    android-support-v7-appcompat \
+    android-support-v7-recyclerview
 LOCAL_JAVA_LANGUAGE_VERSION := 1.7
 include $(BUILD_STATIC_JAVA_LIBRARY)
 
diff --git a/design/src/android/support/design/internal/NavigationMenuItemView.java b/design/src/android/support/design/internal/NavigationMenuItemView.java
index 1e2c928..0423345 100644
--- a/design/src/android/support/design/internal/NavigationMenuItemView.java
+++ b/design/src/android/support/design/internal/NavigationMenuItemView.java
@@ -108,8 +108,7 @@
 
     private StateListDrawable createDefaultBackground() {
         TypedValue value = new TypedValue();
-        if (getContext().getTheme().resolveAttribute(
-                android.support.v7.appcompat.R.attr.colorControlHighlight, value, true)) {
+        if (getContext().getTheme().resolveAttribute(R.attr.colorControlHighlight, value, true)) {
             StateListDrawable drawable = new StateListDrawable();
             drawable.addState(CHECKED_STATE_SET, new ColorDrawable(value.data));
             drawable.addState(EMPTY_STATE_SET, new ColorDrawable(Color.TRANSPARENT));
diff --git a/design/src/android/support/design/widget/CollapsingTextHelper.java b/design/src/android/support/design/widget/CollapsingTextHelper.java
index 4a95a13..6f8d51c 100644
--- a/design/src/android/support/design/widget/CollapsingTextHelper.java
+++ b/design/src/android/support/design/widget/CollapsingTextHelper.java
@@ -194,26 +194,19 @@
     }
 
     void setCollapsedTextAppearance(int resId) {
-        TypedArray a = mView.getContext().obtainStyledAttributes(resId,
-                android.support.v7.appcompat.R.styleable.TextAppearance);
-        if (a.hasValue(android.support.v7.appcompat.R.styleable.TextAppearance_android_textColor)) {
+        TypedArray a = mView.getContext().obtainStyledAttributes(resId, R.styleable.TextAppearance);
+        if (a.hasValue(R.styleable.TextAppearance_android_textColor)) {
             mCollapsedTextColor = a.getColor(
-                    android.support.v7.appcompat.R.styleable.TextAppearance_android_textColor,
-                    mCollapsedTextColor);
+                    R.styleable.TextAppearance_android_textColor, mCollapsedTextColor);
         }
-        if (a.hasValue(android.support.v7.appcompat.R.styleable.TextAppearance_android_textSize)) {
+        if (a.hasValue(R.styleable.TextAppearance_android_textSize)) {
             mCollapsedTextSize = a.getDimensionPixelSize(
-                    android.support.v7.appcompat.R.styleable.TextAppearance_android_textSize,
-                    (int) mCollapsedTextSize);
+                    R.styleable.TextAppearance_android_textSize, (int) mCollapsedTextSize);
         }
-        mCollapsedShadowColor = a.getInt(
-                android.support.v7.appcompat.R.styleable.TextAppearance_android_shadowColor, 0);
-        mCollapsedShadowDx = a.getFloat(
-                android.support.v7.appcompat.R.styleable.TextAppearance_android_shadowDx, 0);
-        mCollapsedShadowDy = a.getFloat(
-                android.support.v7.appcompat.R.styleable.TextAppearance_android_shadowDy, 0);
-        mCollapsedShadowRadius = a.getFloat(
-                android.support.v7.appcompat.R.styleable.TextAppearance_android_shadowRadius, 0);
+        mCollapsedShadowColor = a.getInt(R.styleable.TextAppearance_android_shadowColor, 0);
+        mCollapsedShadowDx = a.getFloat(R.styleable.TextAppearance_android_shadowDx, 0);
+        mCollapsedShadowDy = a.getFloat(R.styleable.TextAppearance_android_shadowDy, 0);
+        mCollapsedShadowRadius = a.getFloat(R.styleable.TextAppearance_android_shadowRadius, 0);
         a.recycle();
 
         if (Build.VERSION.SDK_INT >= 16) {
@@ -224,26 +217,19 @@
     }
 
     void setExpandedTextAppearance(int resId) {
-        TypedArray a = mView.getContext().obtainStyledAttributes(resId,
-                android.support.v7.appcompat.R.styleable.TextAppearance);
-        if (a.hasValue(android.support.v7.appcompat.R.styleable.TextAppearance_android_textColor)) {
+        TypedArray a = mView.getContext().obtainStyledAttributes(resId, R.styleable.TextAppearance);
+        if (a.hasValue(R.styleable.TextAppearance_android_textColor)) {
             mExpandedTextColor = a.getColor(
-                    android.support.v7.appcompat.R.styleable.TextAppearance_android_textColor,
-                    mExpandedTextColor);
+                    R.styleable.TextAppearance_android_textColor, mExpandedTextColor);
         }
-        if (a.hasValue(android.support.v7.appcompat.R.styleable.TextAppearance_android_textSize)) {
+        if (a.hasValue(R.styleable.TextAppearance_android_textSize)) {
             mExpandedTextSize = a.getDimensionPixelSize(
-                    android.support.v7.appcompat.R.styleable.TextAppearance_android_textSize,
-                    (int) mExpandedTextSize);
+                    R.styleable.TextAppearance_android_textSize, (int) mExpandedTextSize);
         }
-        mExpandedShadowColor = a.getInt(
-                android.support.v7.appcompat.R.styleable.TextAppearance_android_shadowColor, 0);
-        mExpandedShadowDx = a.getFloat(
-                android.support.v7.appcompat.R.styleable.TextAppearance_android_shadowDx, 0);
-        mExpandedShadowDy = a.getFloat(
-                android.support.v7.appcompat.R.styleable.TextAppearance_android_shadowDy, 0);
-        mExpandedShadowRadius = a.getFloat(
-                android.support.v7.appcompat.R.styleable.TextAppearance_android_shadowRadius, 0);
+        mExpandedShadowColor = a.getInt(R.styleable.TextAppearance_android_shadowColor, 0);
+        mExpandedShadowDx = a.getFloat(R.styleable.TextAppearance_android_shadowDx, 0);
+        mExpandedShadowDy = a.getFloat(R.styleable.TextAppearance_android_shadowDy, 0);
+        mExpandedShadowRadius = a.getFloat(R.styleable.TextAppearance_android_shadowRadius, 0);
         a.recycle();
 
         if (Build.VERSION.SDK_INT >= 16) {
diff --git a/design/src/android/support/design/widget/CollapsingToolbarLayout.java b/design/src/android/support/design/widget/CollapsingToolbarLayout.java
index 1de2909..17fada5 100644
--- a/design/src/android/support/design/widget/CollapsingToolbarLayout.java
+++ b/design/src/android/support/design/widget/CollapsingToolbarLayout.java
@@ -179,7 +179,7 @@
         mCollapsingTextHelper.setExpandedTextAppearance(
                 R.style.TextAppearance_Design_CollapsingToolbar_Expanded);
         mCollapsingTextHelper.setCollapsedTextAppearance(
-                android.support.v7.appcompat.R.style.TextAppearance_AppCompat_Widget_ActionBar_Title);
+                R.style.TextAppearance_AppCompat_Widget_ActionBar_Title);
 
         // Now overlay any custom text appearances
         if (a.hasValue(R.styleable.CollapsingToolbarLayout_expandedTitleTextAppearance)) {
diff --git a/design/src/android/support/design/widget/NavigationView.java b/design/src/android/support/design/widget/NavigationView.java
index 05fdedb..696a7e4 100644
--- a/design/src/android/support/design/widget/NavigationView.java
+++ b/design/src/android/support/design/widget/NavigationView.java
@@ -413,8 +413,7 @@
             return null;
         }
         ColorStateList baseColor = getResources().getColorStateList(value.resourceId);
-        if (!getContext().getTheme().resolveAttribute(
-                    android.support.v7.appcompat.R.attr.colorPrimary, value, true)) {
+        if (!getContext().getTheme().resolveAttribute(R.attr.colorPrimary, value, true)) {
             return null;
         }
         int colorPrimary = value.data;
diff --git a/design/src/android/support/design/widget/TabLayout.java b/design/src/android/support/design/widget/TabLayout.java
index cf3d1eb..1059b9a 100755
--- a/design/src/android/support/design/widget/TabLayout.java
+++ b/design/src/android/support/design/widget/TabLayout.java
@@ -299,12 +299,10 @@
 
         // Text colors/sizes come from the text appearance first
         final TypedArray ta = context.obtainStyledAttributes(mTabTextAppearance,
-                android.support.v7.appcompat.R.styleable.TextAppearance);
+                R.styleable.TextAppearance);
         try {
-            mTabTextSize = ta.getDimensionPixelSize(
-                    android.support.v7.appcompat.R.styleable.TextAppearance_android_textSize, 0);
-            mTabTextColors = ta.getColorStateList(
-                    android.support.v7.appcompat.R.styleable.TextAppearance_android_textColor);
+            mTabTextSize = ta.getDimensionPixelSize(R.styleable.TextAppearance_android_textSize, 0);
+            mTabTextColors = ta.getColorStateList(R.styleable.TextAppearance_android_textColor);
         } finally {
             ta.recycle();
         }
diff --git a/design/src/android/support/design/widget/TextInputLayout.java b/design/src/android/support/design/widget/TextInputLayout.java
index 21c6c53..ffd7a83 100644
--- a/design/src/android/support/design/widget/TextInputLayout.java
+++ b/design/src/android/support/design/widget/TextInputLayout.java
@@ -494,7 +494,7 @@
                     // Probably caused by our theme not extending from Theme.Design*. Instead
                     // we manually set something appropriate
                     mErrorView.setTextAppearance(getContext(),
-                            android.support.v7.appcompat.R.style.TextAppearance_AppCompat_Caption);
+                            R.style.TextAppearance_AppCompat_Caption);
                     mErrorView.setTextColor(ContextCompat.getColor(
                             getContext(), R.color.design_textinput_error_color_light));
                 }
@@ -615,7 +615,7 @@
                     // Probably caused by our theme not extending from Theme.Design*. Instead
                     // we manually set something appropriate
                     mCounterView.setTextAppearance(getContext(),
-                            android.support.v7.appcompat.R.style.TextAppearance_AppCompat_Caption);
+                            R.style.TextAppearance_AppCompat_Caption);
                     mCounterView.setTextColor(ContextCompat.getColor(
                             getContext(), R.color.design_textinput_error_color_light));
                 }
diff --git a/design/src/android/support/design/widget/ThemeUtils.java b/design/src/android/support/design/widget/ThemeUtils.java
index ffdc3f4..327a44d 100644
--- a/design/src/android/support/design/widget/ThemeUtils.java
+++ b/design/src/android/support/design/widget/ThemeUtils.java
@@ -22,9 +22,7 @@
 
 class ThemeUtils {
 
-    private static final int[] APPCOMPAT_CHECK_ATTRS = {
-            android.support.v7.appcompat.R.attr.colorPrimary
-    };
+    private static final int[] APPCOMPAT_CHECK_ATTRS = { R.attr.colorPrimary };
 
     static void checkAppCompatTheme(Context context) {
         TypedArray a = context.obtainStyledAttributes(APPCOMPAT_CHECK_ATTRS);
diff --git a/documents-archive/Android.mk b/documents-archive/Android.mk
index 826552c..44c9f66 100644
--- a/documents-archive/Android.mk
+++ b/documents-archive/Android.mk
@@ -15,24 +15,15 @@
 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-documents-archive \
-#       android-support-v4 \
-#       android-support-annotations
-#
-# in their makefiles to include the resources and their dependencies in their package.
+# The R class is automatically excluded from the generated library.
+# Applications that use this library must specify LOCAL_RESOURCE_DIR
+# in their makefiles to include the resources in their package.
 include $(CLEAR_VARS)
-LOCAL_USE_AAPT2 := true
 LOCAL_MODULE := android-support-documents-archive
 LOCAL_SDK_VERSION := $(SUPPORT_CURRENT_SDK_VERSION)
-LOCAL_AIDL_INCLUDES := $(LOCAL_PATH)/src
+LOCAL_AIDL_INCLUDES := $LOCAL_PATH/src
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
-LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res
-LOCAL_SHARED_ANDROID_LIBRARIES := \
-    android-support-annotations \
+LOCAL_JAVA_LIBRARIES := android-support-annotations \
     android-support-v4
-LOCAL_JAR_EXCLUDE_FILES := none
 LOCAL_JAVA_LANGUAGE_VERSION := 1.7
 include $(BUILD_STATIC_JAVA_LIBRARY)
diff --git a/percent/Android.mk b/percent/Android.mk
index 26c5dd4..6e04560 100644
--- a/percent/Android.mk
+++ b/percent/Android.mk
@@ -14,22 +14,29 @@
 
 LOCAL_PATH := $(call my-dir)
 
-# Here is the final static library that apps can link against.
-# Applications that use this library must include it with
-#
-#   LOCAL_STATIC_ANDROID_LIBRARIES := \
-#       android-support-percent \
-#       android-support-v4
-#
+# Build the resources using the latest applicable SDK version.
+# We do this here because the final static library must be compiled with an older
+# SDK version than the resources.  The resources library and the R class that it
+# contains will not be linked into the final static library.
 include $(CLEAR_VARS)
-LOCAL_USE_AAPT2 := true
+LOCAL_MODULE := android-support-percent-res
+LOCAL_SDK_VERSION := $(SUPPORT_CURRENT_SDK_VERSION)
+LOCAL_SRC_FILES := $(call all-java-files-under, dummy)
+LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res
+LOCAL_JAR_EXCLUDE_FILES := none
+LOCAL_JAVA_LANGUAGE_VERSION := 1.7
+include $(BUILD_STATIC_JAVA_LIBRARY)
+
+# Here is the final static library that apps can link against.
+# The R class is automatically excluded from the generated library.
+# Applications that use this library must specify LOCAL_RESOURCE_DIR
+# in their makefiles to include the resources in their package.
+include $(CLEAR_VARS)
 LOCAL_MODULE := android-support-percent
 LOCAL_SDK_VERSION := 8
-LOCAL_SDK_RES_VERSION := $(SUPPORT_CURRENT_SDK_VERSION)
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
-LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res
-LOCAL_SHARED_ANDROID_LIBRARIES := android-support-v4
-LOCAL_JAR_EXCLUDE_FILES := none
+LOCAL_JAVA_LIBRARIES := android-support-percent-res \
+    android-support-v4
 LOCAL_JAVA_LANGUAGE_VERSION := 1.7
 include $(BUILD_STATIC_JAVA_LIBRARY)
 
diff --git a/v14/preference/Android.mk b/v14/preference/Android.mk
index 800cac1..f01c53f 100644
--- a/v14/preference/Android.mk
+++ b/v14/preference/Android.mk
@@ -14,32 +14,40 @@
 
 LOCAL_PATH := $(call my-dir)
 
+# Build the resources using the latest applicable SDK version.
+# We do this here because the final static library must be compiled with an older
+# SDK version than the resources.  The resources library and the R class that it
+# contains will not be linked into the final static library.
+include $(CLEAR_VARS)
+LOCAL_MODULE := android-support-v14-preference-res
+LOCAL_SRC_FILES := $(call all-java-files-under, ../../v7/preference/constants)
+LOCAL_SDK_VERSION := $(SUPPORT_CURRENT_SDK_VERSION)
+LOCAL_RESOURCE_DIR := \
+        frameworks/support/v7/appcompat/res \
+        frameworks/support/v7/preference/res \
+        $(LOCAL_PATH)/res
+LOCAL_AAPT_FLAGS := \
+	--auto-add-overlay
+LOCAL_JAR_EXCLUDE_FILES := none
+LOCAL_JAVA_LANGUAGE_VERSION := 1.7
+include $(BUILD_STATIC_JAVA_LIBRARY)
+
 # Here is the final static library that apps can link against.
-# Applications that use this library must specify
-#
-#   LOCAL_STATIC_ANDROID_LIBRARIES := \
-#       android-support-v14-preference \
-#       android-support-v7-preference \
-#       android-support-v7-appcompat \
-#       android-support-v7-recyclerview \
-#       android-support-v4 \
-#       android-support-annotations
-#
+# The R class is automatically excluded from the generated library.
+# Applications that use this library must specify LOCAL_RESOURCE_DIR
 # in their makefiles to include the resources in their package.
 include $(CLEAR_VARS)
-LOCAL_USE_AAPT2 := true
 LOCAL_MODULE := android-support-v14-preference
 LOCAL_SDK_VERSION := 14
-LOCAL_SDK_RES_VERSION := $(SUPPORT_CURRENT_SDK_VERSION)
 LOCAL_SRC_FILES := $(call all-java-files-under,src)
-LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res
-LOCAL_SHARED_ANDROID_LIBRARIES := \
-    android-support-v7-preference \
-    android-support-v7-appcompat \
-    android-support-v7-recyclerview \
-    android-support-v4 \
-    android-support-annotations
-LOCAL_JAR_EXCLUDE_FILES := none
+# LOCAL_STATIC_JAVA_LIBRARIES :=
+LOCAL_JAVA_LIBRARIES := \
+        android-support-v4 \
+        android-support-v7-appcompat \
+        android-support-v7-recyclerview \
+        android-support-v7-preference \
+        android-support-annotations \
+        android-support-v14-preference-res
 LOCAL_JAVA_LANGUAGE_VERSION := 1.7
 include $(BUILD_STATIC_JAVA_LIBRARY)
 
diff --git a/v14/preference/src/android/support/v14/preference/MultiSelectListPreference.java b/v14/preference/src/android/support/v14/preference/MultiSelectListPreference.java
index 1695e92..8316b0d 100644
--- a/v14/preference/src/android/support/v14/preference/MultiSelectListPreference.java
+++ b/v14/preference/src/android/support/v14/preference/MultiSelectListPreference.java
@@ -53,16 +53,16 @@
         super(context, attrs, defStyleAttr, defStyleRes);
 
         final TypedArray a = context.obtainStyledAttributes(attrs,
-                android.support.v7.preference.R.styleable.MultiSelectListPreference, defStyleAttr,
+                R.styleable.MultiSelectListPreference, defStyleAttr,
                 defStyleRes);
 
         mEntries = TypedArrayUtils.getTextArray(a,
-                android.support.v7.preference.R.styleable.MultiSelectListPreference_entries,
-                android.support.v7.preference.R.styleable.MultiSelectListPreference_android_entries);
+                R.styleable.MultiSelectListPreference_entries,
+                R.styleable.MultiSelectListPreference_android_entries);
 
         mEntryValues = TypedArrayUtils.getTextArray(a,
-                android.support.v7.preference.R.styleable.MultiSelectListPreference_entryValues,
-                android.support.v7.preference.R.styleable.MultiSelectListPreference_android_entryValues);
+                R.styleable.MultiSelectListPreference_entryValues,
+                R.styleable.MultiSelectListPreference_android_entryValues);
 
         a.recycle();
     }
@@ -72,8 +72,7 @@
     }
 
     public MultiSelectListPreference(Context context, AttributeSet attrs) {
-        this(context, attrs, TypedArrayUtils.getAttr(context,
-                android.support.v7.preference.R.attr.dialogPreferenceStyle,
+        this(context, attrs, TypedArrayUtils.getAttr(context, R.attr.dialogPreferenceStyle,
                 android.R.attr.dialogPreferenceStyle));
     }
 
diff --git a/v14/preference/src/android/support/v14/preference/PreferenceFragment.java b/v14/preference/src/android/support/v14/preference/PreferenceFragment.java
index bf92f89..52552a6 100644
--- a/v14/preference/src/android/support/v14/preference/PreferenceFragment.java
+++ b/v14/preference/src/android/support/v14/preference/PreferenceFragment.java
@@ -135,7 +135,7 @@
 
     private Context mStyledContext;
 
-    private int mLayoutResId = android.support.v7.preference.R.layout.preference_list_fragment;
+    private int mLayoutResId = R.layout.preference_list_fragment;
 
     private final DividerDecoration mDividerDecoration = new DividerDecoration();
 
@@ -207,8 +207,7 @@
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         final TypedValue tv = new TypedValue();
-        getActivity().getTheme().resolveAttribute(
-                android.support.v7.preference.R.attr.preferenceTheme, tv, true);
+        getActivity().getTheme().resolveAttribute(R.attr.preferenceTheme, tv, true);
         final int theme = tv.resourceId;
         if (theme <= 0) {
             throw new IllegalStateException("Must specify preferenceTheme in theme");
@@ -245,8 +244,7 @@
 
         TypedArray a = mStyledContext.obtainStyledAttributes(null,
                 R.styleable.PreferenceFragment,
-                TypedArrayUtils.getAttr(mStyledContext,
-                        android.support.v7.preference.R.attr.preferenceFragmentStyle,
+                TypedArrayUtils.getAttr(mStyledContext, R.attr.preferenceFragmentStyle,
                         AndroidResources.ANDROID_R_PREFERENCE_FRAGMENT_STYLE),
                 0);
 
@@ -260,8 +258,7 @@
 
         // Need to theme the inflater to pick up the preferenceFragmentListStyle
         final TypedValue tv = new TypedValue();
-        getActivity().getTheme().resolveAttribute(
-                android.support.v7.preference.R.attr.preferenceTheme, tv, true);
+        getActivity().getTheme().resolveAttribute(R.attr.preferenceTheme, tv, true);
         final int theme = tv.resourceId;
 
         final Context themedContext = new ContextThemeWrapper(inflater.getContext(), theme);
@@ -570,8 +567,7 @@
     public RecyclerView onCreateRecyclerView(LayoutInflater inflater, ViewGroup parent,
             Bundle savedInstanceState) {
         RecyclerView recyclerView = (RecyclerView) inflater
-                .inflate(android.support.v7.preference.R.layout.preference_recyclerview,
-                        parent, false);
+                .inflate(R.layout.preference_recyclerview, parent, false);
 
         recyclerView.setLayoutManager(onCreateLayoutManager());
 
diff --git a/v14/preference/src/android/support/v14/preference/SwitchPreference.java b/v14/preference/src/android/support/v14/preference/SwitchPreference.java
index 6e6b7f8..ac2a9c6 100644
--- a/v14/preference/src/android/support/v14/preference/SwitchPreference.java
+++ b/v14/preference/src/android/support/v14/preference/SwitchPreference.java
@@ -122,8 +122,7 @@
      * @param attrs Style attributes that differ from the default
      */
     public SwitchPreference(Context context, AttributeSet attrs) {
-        this(context, attrs, TypedArrayUtils.getAttr(context,
-                android.support.v7.preference.R.attr.switchPreferenceStyle,
+        this(context, attrs, TypedArrayUtils.getAttr(context, R.attr.switchPreferenceStyle,
                 android.R.attr.switchPreferenceStyle));
     }
 
@@ -217,7 +216,7 @@
             return;
         }
 
-        View switchView = view.findViewById(android.support.v7.preference.R.id.switchWidget);
+        View switchView = view.findViewById(R.id.switchWidget);
         syncSwitchView(switchView);
 
         View summaryView = view.findViewById(android.R.id.summary);
diff --git a/v17/leanback/Android.mk b/v17/leanback/Android.mk
index 0da668d..d55ae61 100644
--- a/v17/leanback/Android.mk
+++ b/v17/leanback/Android.mk
@@ -19,11 +19,12 @@
 # SDK version than the resources.  The resources library and the R class that it
 # contains will not be linked into the final static library.
 include $(CLEAR_VARS)
-LOCAL_USE_AAPT2 := true
 LOCAL_MODULE := android-support-v17-leanback-res
 LOCAL_SDK_VERSION := $(SUPPORT_CURRENT_SDK_VERSION)
 LOCAL_SRC_FILES := $(call all-java-files-under, dummy)
 LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res
+LOCAL_AAPT_FLAGS := \
+        --auto-add-overlay
 LOCAL_JAR_EXCLUDE_FILES := none
 LOCAL_JAVA_LANGUAGE_VERSION := 1.7
 include $(BUILD_STATIC_JAVA_LIBRARY)
@@ -98,32 +99,20 @@
 # -----------------------------------------------------------------------
 
 # Here is the final static library that apps can link against.
-# Applications that use this library must specify
-#
-#   LOCAL_STATIC_ANDROID_LIBRARIES := \
-#       android-support-v17-leanback \
-#       android-support-v7-recyclerview \
-#       android-support-v4
-#
-# in their makefiles to include the resources and their dependencies in their package.
+# The R class is automatically excluded from the generated library.
+# Applications that use this library must specify LOCAL_RESOURCE_DIR
+# in their makefiles to include the resources in their package.
 include $(CLEAR_VARS)
-LOCAL_USE_AAPT2 := true
 LOCAL_MODULE := android-support-v17-leanback
 LOCAL_SDK_VERSION := 17
-LOCAL_SDK_RES_VERSION := $(SUPPORT_CURRENT_SDK_VERSION)
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
-LOCAL_STATIC_JAVA_LIBRARIES := \
-    android-support-v17-leanback-kitkat \
-    android-support-v17-leanback-jbmr2 \
-    android-support-v17-leanback-api23 \
-    android-support-v17-leanback-api21 \
-    android-support-v17-leanback-common
-LOCAL_STATIC_ANDROID_LIBRARIES := \
-    android-support-v17-leanback-res
-LOCAL_SHARED_ANDROID_LIBRARIES := \
-    android-support-v7-recyclerview \
-    android-support-v4
-LOCAL_JAR_EXCLUDE_FILES := none
+LOCAL_STATIC_JAVA_LIBRARIES := android-support-v17-leanback-kitkat android-support-v17-leanback-jbmr2 \
+        android-support-v17-leanback-api23 \
+        android-support-v17-leanback-api21 android-support-v17-leanback-common
+LOCAL_JAVA_LIBRARIES := \
+        android-support-v4 \
+        android-support-v7-recyclerview \
+        android-support-v17-leanback-res
 LOCAL_JAVA_LANGUAGE_VERSION := 1.7
 include $(BUILD_STATIC_JAVA_LIBRARY)
 
diff --git a/v17/preference-leanback/Android.mk b/v17/preference-leanback/Android.mk
index cd81287..c14c4a6 100644
--- a/v17/preference-leanback/Android.mk
+++ b/v17/preference-leanback/Android.mk
@@ -14,27 +14,25 @@
 
 LOCAL_PATH := $(call my-dir)
 
-# Android libraries referenced by this module's resources.
-resource_libs := \
-    android-support-v17-leanback \
-    android-support-v14-preference \
-    android-support-v7-preference \
-    android-support-v7-appcompat \
-    android-support-v7-recyclerview
-
 # Build the resources using the latest applicable SDK version.
 # We do this here because the final static library must be compiled with an older
 # SDK version than the resources.  The resources library and the R class that it
 # contains will not be linked into the final static library.
 include $(CLEAR_VARS)
-LOCAL_USE_AAPT2 := true
 LOCAL_MODULE := android-support-v17-preference-leanback-res
 LOCAL_SDK_VERSION := $(SUPPORT_CURRENT_SDK_VERSION)
 LOCAL_SRC_FILES := $(call all-java-files-under, dummy)
-LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res
-LOCAL_SHARED_ANDROID_LIBRARIES := $(resource_libs)
-LOCAL_JAVA_LANGUAGE_VERSION := 1.7
+LOCAL_RESOURCE_DIR := \
+        frameworks/support/v7/appcompat/res \
+        frameworks/support/v7/recyclerview/res \
+        frameworks/support/v7/preference/res \
+        frameworks/support/v14/preference/res \
+        frameworks/support/v17/leanback/res \
+        $(LOCAL_PATH)/res
+LOCAL_AAPT_FLAGS := \
+        --auto-add-overlay
 LOCAL_JAR_EXCLUDE_FILES := none
+LOCAL_JAVA_LANGUAGE_VERSION := 1.7
 include $(BUILD_STATIC_JAVA_LIBRARY)
 
 support_module_src_files := $(LOCAL_SRC_FILES)
@@ -46,43 +44,32 @@
 LOCAL_MODULE := android-support-v17-preference-leanback-api21
 LOCAL_SDK_VERSION := 21
 LOCAL_SRC_FILES := $(call all-java-files-under, api21)
-LOCAL_JAVA_LIBRARIES := \
-    android-support-v17-preference-leanback-res \
-    android-support-v17-leanback
+LOCAL_JAVA_LIBRARIES := android-support-v17-preference-leanback-res \
+        android-support-v17-leanback
 LOCAL_JAVA_LANGUAGE_VERSION := 1.7
 include $(BUILD_STATIC_JAVA_LIBRARY)
 
 support_module_src_files += $(LOCAL_SRC_FILES)
 
 # Here is the final static library that apps can link against.
-# Applications that use this library must specify
-#
-#   LOCAL_STATIC_ANDROID_LIBRARIES := \
-#       android-support-v17-preference-leanback \
-#       android-support-v17-leanback \
-#       android-support-v14-preference \
-#       android-support-v7-preference \
-#       android-support-v7-appcompat \
-#       android-support-v7-recyclerview \
-#       android-support-v4 \
-#       android-support-annotions
-#
+# The R class is automatically excluded from the generated library.
+# Applications that use this library must specify LOCAL_RESOURCE_DIR
 # in their makefiles to include the resources in their package.
 include $(CLEAR_VARS)
-LOCAL_USE_AAPT2 := true
 LOCAL_MODULE := android-support-v17-preference-leanback
 LOCAL_SDK_VERSION := 17
-LOCAL_SDK_RES_VERSION := $(SUPPORT_CURRENT_SDK_VERSION)
 LOCAL_SRC_FILES := $(call all-java-files-under,src)
 LOCAL_STATIC_JAVA_LIBRARIES := \
-    android-support-v17-preference-leanback-api21
-LOCAL_STATIC_ANDROID_LIBRARIES := \
-    android-support-v17-preference-leanback-res
-LOCAL_SHARED_ANDROID_LIBRARIES := \
-    $(resource_libs) \
-    android-support-v4 \
-    android-support-annotations
-LOCAL_JAR_EXCLUDE_FILES := none
+        android-support-v17-preference-leanback-api21
+LOCAL_JAVA_LIBRARIES := \
+        android-support-v4 \
+        android-support-v7-appcompat \
+        android-support-v7-recyclerview \
+        android-support-v7-preference \
+        android-support-v14-preference \
+        android-support-v17-leanback \
+        android-support-annotations \
+        android-support-v17-preference-leanback-res
 LOCAL_JAVA_LANGUAGE_VERSION := 1.7
 include $(BUILD_STATIC_JAVA_LIBRARY)
 
diff --git a/v4/Android.mk b/v4/Android.mk
index 1e8adad..dd24664 100644
--- a/v4/Android.mk
+++ b/v4/Android.mk
@@ -264,15 +264,12 @@
 
 # Here is the final static library that apps can link against.
 include $(CLEAR_VARS)
-LOCAL_USE_AAPT2 := true
 LOCAL_MODULE := android-support-v4
 LOCAL_SDK_VERSION := 4
 LOCAL_AIDL_INCLUDES := frameworks/support/v4/java
 LOCAL_SRC_FILES := $(call all-java-files-under, java) \
     $(call all-Iaidl-files-under, java)
-LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res
 LOCAL_STATIC_JAVA_LIBRARIES += android-support-v4-api24
-LOCAL_JAR_EXCLUDE_FILES := none
 LOCAL_JAVA_LANGUAGE_VERSION := 1.7
 include $(BUILD_STATIC_JAVA_LIBRARY)
 
diff --git a/v7/appcompat/Android.mk b/v7/appcompat/Android.mk
index 6d11fcb..6816f54 100644
--- a/v7/appcompat/Android.mk
+++ b/v7/appcompat/Android.mk
@@ -15,25 +15,19 @@
 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-appcompat \
-#       android-support-v4
-#
-# in their makefiles to include the resources and their dependencies in their package.
+# The R class is automatically excluded from the generated library.
+# Applications that use this library must specify LOCAL_RESOURCE_DIR
+# in their makefiles to include the resources in their package.
 include $(CLEAR_VARS)
-LOCAL_USE_AAPT2 := true
 LOCAL_MODULE := android-support-v7-appcompat
 LOCAL_SDK_VERSION := $(SUPPORT_CURRENT_SDK_VERSION)
 LOCAL_SRC_FILES := $(call all-java-files-under,src)
 LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res
-LOCAL_STATIC_JAVA_LIBRARIES := \
-    android-support-vectordrawable \
-    android-support-animatedvectordrawable
+LOCAL_STATIC_JAVA_LIBRARIES := android-support-vectordrawable \
+        android-support-animatedvectordrawable
 LOCAL_JAVA_LIBRARIES := android-support-v4
-LOCAL_AAPT_FLAGS := --no-version-vectors
-LOCAL_JAR_EXCLUDE_FILES := none
+LOCAL_AAPT_FLAGS += --auto-add-overlay \
+        --no-version-vectors
 LOCAL_JAVA_LANGUAGE_VERSION := 1.7
 include $(BUILD_STATIC_JAVA_LIBRARY)
 
diff --git a/v7/cardview/Android.mk b/v7/cardview/Android.mk
index bb8ff9f..7fa5cec 100644
--- a/v7/cardview/Android.mk
+++ b/v7/cardview/Android.mk
@@ -19,7 +19,6 @@
 # SDK version than the resources.  The resources library and the R class that it
 # contains will not be linked into the final static library.
 include $(CLEAR_VARS)
-LOCAL_USE_AAPT2 := true
 LOCAL_MODULE := android-support-v7-cardview-res
 LOCAL_SDK_VERSION := $(SUPPORT_CURRENT_SDK_VERSION)
 LOCAL_SRC_FILES := $(call all-java-files-under, dummy)
@@ -73,8 +72,9 @@
 LOCAL_MODULE := android-support-v7-cardview-api21
 LOCAL_SDK_VERSION := 21
 LOCAL_SRC_FILES := $(call all-java-files-under, api21)
-LOCAL_STATIC_JAVA_LIBRARIES := android-support-v7-cardview-jellybean-mr1
-LOCAL_JAVA_LIBRARIES := android-support-v7-cardview-res \
+LOCAL_STATIC_JAVA_LIBRARIES := android-support-v7-cardview-base \
+    android-support-v7-cardview-jellybean-mr1
+LOCAL_JAVA_LIBRARIES := android-support-v7-cardview-res  \
     android-support-annotations
 LOCAL_JAVA_LANGUAGE_VERSION := 1.7
 include $(BUILD_STATIC_JAVA_LIBRARY)
@@ -82,21 +82,16 @@
 support_module_src_files += $(LOCAL_SRC_FILES)
 
 # 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-cardview
-#
+# The R class is automatically excluded from the generated library.
+# Applications that use this library must specify LOCAL_RESOURCE_DIR
 # in their makefiles to include the resources in their package.
 include $(CLEAR_VARS)
-LOCAL_USE_AAPT2 := true
 LOCAL_MODULE := android-support-v7-cardview
 LOCAL_SDK_VERSION := 7
-LOCAL_SDK_RES_VERSION := $(SUPPORT_CURRENT_SDK_VERSION)
 LOCAL_SRC_FILES := $(call all-java-files-under,src)
 LOCAL_STATIC_JAVA_LIBRARIES := android-support-v7-cardview-api21
-LOCAL_JAVA_LIBRARIES := android-support-annotations
-LOCAL_STATIC_ANDROID_LIBRARIES := android-support-v7-cardview-res
-LOCAL_JAR_EXCLUDE_FILES := none
+LOCAL_JAVA_LIBRARIES := android-support-v7-cardview-res \
+    android-support-annotations
 LOCAL_JAVA_LANGUAGE_VERSION := 1.7
 include $(BUILD_STATIC_JAVA_LIBRARY)
 
diff --git a/v7/gridlayout/Android.mk b/v7/gridlayout/Android.mk
index 0c56b6e..4617db6 100644
--- a/v7/gridlayout/Android.mk
+++ b/v7/gridlayout/Android.mk
@@ -15,21 +15,15 @@
 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-gridlayout \
-#       android-support-v4
-#
-# in their makefiles to include the resources and their dependencies in their package.
+# The R class is automatically excluded from the generated library.
+# Applications that use this library must specify LOCAL_RESOURCE_DIR
+# in their makefiles to include the resources in their package.
 include $(CLEAR_VARS)
-LOCAL_USE_AAPT2 := true
 LOCAL_MODULE := android-support-v7-gridlayout
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
 LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res
 LOCAL_SDK_VERSION := 7
-LOCAL_SHARED_ANDROID_LIBRARIES := android-support-v4
-LOCAL_JAR_EXCLUDE_FILES := none
+LOCAL_JAVA_LIBRARIES := android-support-v4
 LOCAL_JAVA_LANGUAGE_VERSION := 1.7
 include $(BUILD_STATIC_JAVA_LIBRARY)
 
diff --git a/v7/mediarouter/Android.mk b/v7/mediarouter/Android.mk
index a7b2656..ada74c5 100644
--- a/v7/mediarouter/Android.mk
+++ b/v7/mediarouter/Android.mk
@@ -16,14 +16,17 @@
 
 # Build the resources using the latest applicable SDK version.
 # We do this here because the final static library must be compiled with an older
-# SDK version than the resources.
+# SDK version than the resources.  The resources library and the R class that it
+# contains will not be linked into the final static library.
 include $(CLEAR_VARS)
-LOCAL_USE_AAPT2 := true
 LOCAL_MODULE := android-support-v7-mediarouter-res
 LOCAL_SDK_VERSION := $(SUPPORT_CURRENT_SDK_VERSION)
 LOCAL_SRC_FILES := $(call all-java-files-under, dummy)
-LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res
-LOCAL_SHARED_ANDROID_LIBRARIES := android-support-v7-appcompat
+LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res \
+	frameworks/support/v7/appcompat/res
+LOCAL_AAPT_FLAGS := \
+	--auto-add-overlay \
+	--extra-packages android.support.v7.appcompat
 LOCAL_JAR_EXCLUDE_FILES := none
 LOCAL_JAVA_LANGUAGE_VERSION := 1.7
 include $(BUILD_STATIC_JAVA_LIBRARY)
@@ -74,28 +77,17 @@
 support_module_src_files += $(LOCAL_SRC_FILES)
 
 # 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-mediarouter \
-#       android-support-v7-appcompat \
-#       android-support-v7-palette \
-#       android-support-v4
-#
-# in their makefiles to include the resources and their dependencies in their package.
+# The R class is automatically excluded from the generated library.
+# Applications that use this library must specify LOCAL_RESOURCE_DIR
+# in their makefiles to include the resources in their package.
 include $(CLEAR_VARS)
-LOCAL_USE_AAPT2 := true
 LOCAL_MODULE := android-support-v7-mediarouter
 LOCAL_SDK_VERSION := 7
-LOCAL_SDK_RES_VERSION := $(SUPPORT_CURRENT_SDK_VERSION)
 LOCAL_SRC_FILES := $(call all-java-files-under,src)
 LOCAL_STATIC_JAVA_LIBRARIES := android-support-v7-mediarouter-api24
-LOCAL_STATIC_ANDROID_LIBRARIES := android-support-v7-mediarouter-res
-LOCAL_SHARED_ANDROID_LIBRARIES := \
+LOCAL_JAVA_LIBRARIES := android-support-v4 android-support-v7-mediarouter-res \
     android-support-v7-appcompat \
-    android-support-v7-palette \
-    android-support-v4
-LOCAL_JAR_EXCLUDE_FILES := none
+    android-support-v7-palette
 LOCAL_JAVA_LANGUAGE_VERSION := 1.7
 include $(BUILD_STATIC_JAVA_LIBRARY)
 
diff --git a/v7/mediarouter/src/android/support/v7/app/MediaRouteVolumeSlider.java b/v7/mediarouter/src/android/support/v7/app/MediaRouteVolumeSlider.java
index a7a0dd3..a7aafd2 100644
--- a/v7/mediarouter/src/android/support/v7/app/MediaRouteVolumeSlider.java
+++ b/v7/mediarouter/src/android/support/v7/app/MediaRouteVolumeSlider.java
@@ -42,7 +42,7 @@
     }
 
     public MediaRouteVolumeSlider(Context context, AttributeSet attrs) {
-        this(context, attrs, android.support.v7.appcompat.R.attr.seekBarStyle);
+        this(context, attrs, R.attr.seekBarStyle);
     }
 
     public MediaRouteVolumeSlider(Context context, AttributeSet attrs, int defStyleAttr) {
diff --git a/v7/mediarouter/src/android/support/v7/app/MediaRouterThemeHelper.java b/v7/mediarouter/src/android/support/v7/app/MediaRouterThemeHelper.java
index 3d55951..25b1d1d 100644
--- a/v7/mediarouter/src/android/support/v7/app/MediaRouterThemeHelper.java
+++ b/v7/mediarouter/src/android/support/v7/app/MediaRouterThemeHelper.java
@@ -84,8 +84,7 @@
     }
 
     public static @ControllerColorType int getControllerColor(Context context, int style) {
-        int primaryColor = getThemeColor(context, style,
-                android.support.v7.appcompat.R.attr.colorPrimary);
+        int primaryColor = getThemeColor(context, style, R.attr.colorPrimary);
         if (ColorUtils.calculateContrast(COLOR_WHITE_ON_DARK_BACKGROUND, primaryColor)
                 >= MIN_CONTRAST) {
             return COLOR_WHITE_ON_DARK_BACKGROUND;
@@ -94,23 +93,20 @@
     }
 
     public static int getButtonTextColor(Context context) {
-        int primaryColor = getThemeColor(context, 0,
-                android.support.v7.appcompat.R.attr.colorPrimary);
+        int primaryColor = getThemeColor(context, 0, R.attr.colorPrimary);
         int backgroundColor = getThemeColor(context, 0, android.R.attr.colorBackground);
 
         if (ColorUtils.calculateContrast(primaryColor, backgroundColor) < MIN_CONTRAST) {
             // Default to colorAccent if the contrast ratio is low.
-            return getThemeColor(context, 0, android.support.v7.appcompat.R.attr.colorAccent);
+            return getThemeColor(context, 0, R.attr.colorAccent);
         }
         return primaryColor;
     }
 
     public static void setMediaControlsBackgroundColor(
             Context context, View mainControls, View groupControls, boolean hasGroup) {
-        int primaryColor = getThemeColor(context, 0,
-                android.support.v7.appcompat.R.attr.colorPrimary);
-        int primaryDarkColor = getThemeColor(context, 0,
-                android.support.v7.appcompat.R.attr.colorPrimaryDark);
+        int primaryColor = getThemeColor(context, 0, R.attr.colorPrimary);
+        int primaryDarkColor = getThemeColor(context, 0, R.attr.colorPrimaryDark);
         if (hasGroup && getControllerColor(context, 0) == COLOR_DARK_ON_LIGHT_BACKGROUND) {
             // Instead of showing dark controls in a possibly dark (i.e. the primary dark), model
             // the white dialog and use the primary color for the group controls.
@@ -139,8 +135,7 @@
 
     private static boolean isLightTheme(Context context) {
         TypedValue value = new TypedValue();
-        return context.getTheme().resolveAttribute(
-                android.support.v7.appcompat.R.attr.isLightTheme, value, true)
+        return context.getTheme().resolveAttribute(R.attr.isLightTheme, value, true)
                 && value.data != 0;
     }
 
diff --git a/v7/palette/Android.mk b/v7/palette/Android.mk
index 17d0de7..0c4cb05 100644
--- a/v7/palette/Android.mk
+++ b/v7/palette/Android.mk
@@ -15,22 +15,12 @@
 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_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_MANIFEST_FILE := $(LOCAL_PATH)/src/main/AndroidManifest.xml
+LOCAL_JAVA_LIBRARIES += android-support-v4
 LOCAL_JAVA_LANGUAGE_VERSION := 1.7
 include $(BUILD_STATIC_JAVA_LIBRARY)
 
diff --git a/v7/preference/Android.mk b/v7/preference/Android.mk
index 53acb08..85ded02 100644
--- a/v7/preference/Android.mk
+++ b/v7/preference/Android.mk
@@ -14,46 +14,39 @@
 
 LOCAL_PATH := $(call my-dir)
 
-# Build the resources separately because the constants built with the resources need to access
-# the latest SDK but the actual code needs to build against SDK 7.
+# Build the resources using the latest applicable SDK version.
+# We do this here because the final static library must be compiled with an older
+# SDK version than the resources.  The resources library and the R class that it
+# contains will not be linked into the final static library.
 include $(CLEAR_VARS)
-LOCAL_USE_AAPT2 := true
 LOCAL_MODULE := android-support-v7-preference-res
+LOCAL_SRC_FILES := $(call all-java-files-under, constants)
 LOCAL_SDK_VERSION := $(SUPPORT_CURRENT_SDK_VERSION)
-LOCAL_SRC_FILES := $(call all-java-files-under,constants)
-LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res
-LOCAL_SHARED_ANDROID_LIBRARIES := \
-    android-support-v7-appcompat \
-    android-support-v7-recyclerview
+LOCAL_RESOURCE_DIR := \
+        frameworks/support/v7/appcompat/res \
+        frameworks/support/v7/recyclerview/res \
+        $(LOCAL_PATH)/res
+LOCAL_AAPT_FLAGS := \
+	--auto-add-overlay
 LOCAL_JAR_EXCLUDE_FILES := none
 LOCAL_JAVA_LANGUAGE_VERSION := 1.7
 include $(BUILD_STATIC_JAVA_LIBRARY)
 
 # 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-preference \
-#       android-support-v7-appcompat \
-#       android-support-v7-recyclerview \
-#       android-support-v4 \
-#       android-support-annotations
-#
-# in their makefiles to include the resources and their dependencies in their package.
+# The R class is automatically excluded from the generated library.
+# Applications that use this library must specify LOCAL_RESOURCE_DIR
+# in their makefiles to include the resources in their package.
 include $(CLEAR_VARS)
-LOCAL_USE_AAPT2 := true
 LOCAL_MODULE := android-support-v7-preference
 LOCAL_SDK_VERSION := 7
-LOCAL_SDK_RES_VERSION := $(SUPPORT_CURRENT_SDK_VERSION)
 LOCAL_SRC_FILES := $(call all-java-files-under,src)
-LOCAL_STATIC_ANDROID_LIBRARIES := \
-    android-support-v7-preference-res
-LOCAL_SHARED_ANDROID_LIBRARIES := \
-    android-support-v7-appcompat \
-    android-support-v7-recyclerview \
-    android-support-v4 \
-    android-support-annotations
-LOCAL_JAR_EXCLUDE_FILES := none
+# LOCAL_STATIC_JAVA_LIBRARIES :=
+LOCAL_JAVA_LIBRARIES := \
+        android-support-v4 \
+        android-support-v7-appcompat \
+        android-support-v7-recyclerview \
+        android-support-annotations \
+        android-support-v7-preference-res
 LOCAL_JAVA_LANGUAGE_VERSION := 1.7
 include $(BUILD_STATIC_JAVA_LIBRARY)
 
diff --git a/v7/preference/src/android/support/v7/preference/CheckBoxPreference.java b/v7/preference/src/android/support/v7/preference/CheckBoxPreference.java
index 8ef625b..50ab1db 100644
--- a/v7/preference/src/android/support/v7/preference/CheckBoxPreference.java
+++ b/v7/preference/src/android/support/v7/preference/CheckBoxPreference.java
@@ -109,7 +109,7 @@
             return;
         }
 
-        View checkboxView = view.findViewById(android.support.v7.appcompat.R.id.checkbox);
+        View checkboxView = view.findViewById(R.id.checkbox);
         syncCheckboxView(checkboxView);
 
         View summaryView = view.findViewById(android.R.id.summary);
diff --git a/v7/recyclerview/Android.mk b/v7/recyclerview/Android.mk
index 021296e..1a0819c 100644
--- a/v7/recyclerview/Android.mk
+++ b/v7/recyclerview/Android.mk
@@ -14,29 +14,37 @@
 
 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-recycler-view \
-#       android-support-v4 \
-#       android-support-annotations
-#
-# in their makefiles to include the resources and their dependencies in their package.
+# # Build the resources using the latest applicable SDK version.
+# # We do this here because the final static library must be compiled with an older
+# # SDK version than the resources.  The resources library and the R class that it
+# # contains will not be linked into the final static library.
 include $(CLEAR_VARS)
-LOCAL_USE_AAPT2 := true
-LOCAL_MODULE := android-support-v7-recyclerview
-LOCAL_SDK_VERSION := 7
-LOCAL_SDK_RES_VERSION := $(SUPPORT_CURRENT_SDK_VERSION)
-LOCAL_SRC_FILES := $(call all-java-files-under,src)
+LOCAL_MODULE := android-support-v7-recyclerview-res
+LOCAL_SDK_VERSION := $(SUPPORT_CURRENT_SDK_VERSION)
+LOCAL_SRC_FILES := $(call all-java-files-under, dummy)
 LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res
-LOCAL_SHARED_ANDROID_LIBRARIES := \
-    android-support-v4 \
-    android-support-annotations
+LOCAL_AAPT_FLAGS := \
+	--auto-add-overlay
 LOCAL_JAR_EXCLUDE_FILES := none
 LOCAL_JAVA_LANGUAGE_VERSION := 1.7
 include $(BUILD_STATIC_JAVA_LIBRARY)
 
+# Here is the final static library that apps can link against.
+# The R class is automatically excluded from the generated library.
+# Applications that use this library must specify LOCAL_RESOURCE_DIR
+# in their makefiles to include the resources in their package.
+include $(CLEAR_VARS)
+LOCAL_MODULE := android-support-v7-recyclerview
+LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res
+LOCAL_SDK_VERSION := 7
+LOCAL_SRC_FILES := $(call all-java-files-under,src)
+LOCAL_JAVA_LIBRARIES := \
+        android-support-v4 \
+        android-support-annotations \
+        android-support-v7-recyclerview-res
+LOCAL_JAVA_LANGUAGE_VERSION := 1.7
+include $(BUILD_STATIC_JAVA_LIBRARY)
+
 # API Check
 # ---------------------------------------------
 support_module := $(LOCAL_MODULE)