Move all support library projects to use a single compilation unit

Also cleans up build files to include annotations as an explicit import,
set compileSdkVersion consistently to currentSdk, and remove unnecessary
lines. Removes obsolete API directories in VDC / AVDC.

Because NotificationCompatBase was using @removed APIs, updated that class
to use reflection. Also fixes method visibility in VDC / AVDC.

Bug: 29630077
Test: make and gradle builds successful
Change-Id: Ia9208246837347ce3d8df4adbe6b0ce406d3844a
diff --git a/build.gradle b/build.gradle
index 15f52bf..e47de23 100644
--- a/build.gradle
+++ b/build.gradle
@@ -182,95 +182,6 @@
     files("${project.rootDir}/../../prebuilts/sdk/$apiLevel/android.jar")
 }
 
-/**
- * Populates the sub-project's set of source sets with the specified modules.
- *
- * @param subProject the sub-project to which the modules belong
- * @param apiModules the modules from which to populate
- */
-void createApiSourceSets(Project subProject, List<ApiModule> apiModules) {
-    subProject.ext._apiModules = apiModules
-    subProject.ext.allSS = []
-    if (gradle.ext.studioCompat.enableApiModules) {
-        // nothing to do, they are all modules
-        return
-    }
-    // create a jar task for the api specific internal implementations
-    def internalJar = subProject.tasks.create(name: "internalJar", type: Jar) {
-        baseName "internal_impl"
-    }
-    apiModules.each { ApiModule apiModule ->
-        apiModule.sourceSet = createApiSourceset(subProject, apiModule.folderName, apiModule.folderName,
-                apiModule.apiForSourceSet.toString(), apiModule.prev == null ? null : apiModule.prev.sourceSet)
-        subProject.ext.allSS.add(apiModule.sourceSet)
-    }
-    subProject.android.libraryVariants.all { variant ->
-        variant.javaCompile.dependsOn internalJar
-    }
-}
-
-/**
- * Adds the specified module to the sub-project's set of source sets and
- * internal JAR. Also sets up dependencies, if supplied.
- *
- * @param subProject the sub-project to which the module belongs
- * @param name the name of the module
- * @param folder the module's source folder
- * @param apiLevel the module's compile API level
- * @param previousSource source set dependency (optional)
- * @return a source set for the module
- */
-SourceSet createApiSourceset(Project subProject, String name, String folder, String apiLevel,
-                       SourceSet previousSource) {
-    def sourceSet = subProject.sourceSets.create(name)
-    sourceSet.java.srcDirs = [folder]
-
-    // The Android gradle plugin doesn't touch Java sub-tasks, so we need to
-    // manually set the Java task's boot classpath to the correct Android SDK.
-    def compileJavaTaskName = sourceSet.getCompileJavaTaskName();
-    def compileJavaOptions = subProject.tasks."${compileJavaTaskName}".options
-    compileJavaOptions.bootClasspath = getAndroidPrebuilt(apiLevel)
-
-    // Useful for cleaning up compiler warnings...
-    //compileJavaOptions.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
-
-    def configName = sourceSet.getCompileConfigurationName()
-    subProject.getDependencies().add(configName, getAndroidPrebuilt(apiLevel))
-    if (previousSource != null) {
-        setupDependencies(subProject, configName, previousSource)
-    }
-    subProject.ext.allSS.add(sourceSet)
-    subProject.tasks.internalJar.from sourceSet.output
-    return sourceSet
-}
-
-/**
- * Adds the specified source set as a dependency for the sub-project.
- *
- * @param subProject the sub-project to modify
- * @param configName
- * @param previousSourceSet the source set to add as a dependency
- */
-void setupDependencies(Project subProject, String configName, SourceSet previousSourceSet) {
-    subProject.getDependencies().add(configName, previousSourceSet.output)
-    subProject.getDependencies().add(configName, previousSourceSet.compileClasspath)
-}
-
-void setApiModuleDependencies(Project subProject, DependencyHandler handler, List extraDeps) {
-    if (gradle.ext.studioCompat.enableApiModules) {
-        subProject.android.enforceUniquePackageName=false
-        // add dependency on the latest module
-        handler.compile(project(subProject.ext._apiModules.last().moduleName))
-    } else {
-        handler.compile(files(subProject.tasks.internalJar.archivePath))
-        def firstModule = subProject.ext._apiModules[0]
-        extraDeps.each { dep ->
-            handler."${firstModule.folderName}Compile"(project(dep))
-            handler.compile(project(dep))
-        }
-    }
-}
-
 void registerForDocsTask(Task task, Project subProject, releaseVariant) {
     task.dependsOn releaseVariant.javaCompile
     task.source {
@@ -281,12 +192,6 @@
     }
     task.classpath += files(releaseVariant.javaCompile.classpath) +
             files(releaseVariant.javaCompile.destinationDir)
-
-    if (subProject.hasProperty('allSS')) {
-        subProject.allSS.each { ss ->
-            task.source ss.java
-        }
-    }
 }
 
 // Generates online docs.
@@ -369,8 +274,6 @@
     // current SDK is set in studioCompat.gradle
     project.ext.currentSdk = gradle.ext.currentSdk
     apply plugin: 'maven'
-    project.ext.createApiSourceSets = this.&createApiSourceset
-    project.ext.setApiModuleDependencies = this.&setApiModuleDependencies
 
     version = rootProject.ext.supportVersion
     group = 'com.android.support'
diff --git a/compat/Android.mk b/compat/Android.mk
index 3e1a2a6..ba5b958 100644
--- a/compat/Android.mk
+++ b/compat/Android.mk
@@ -14,181 +14,40 @@
 
 LOCAL_PATH := $(call my-dir)
 
-# A helper sub-library that makes direct use of Gingerbread APIs.
-include $(CLEAR_VARS)
-LOCAL_MODULE := android-support-compat-gingerbread
-LOCAL_SDK_VERSION := 9
-LOCAL_SRC_FILES := $(call all-java-files-under, gingerbread)
-LOCAL_STATIC_JAVA_LIBRARIES := android-support-annotations
-LOCAL_JAVA_LANGUAGE_VERSION := 1.7
-include $(BUILD_STATIC_JAVA_LIBRARY)
-
-# -----------------------------------------------------------------------
-
-# A helper sub-library that makes direct use of Honeycomb APIs.
-include $(CLEAR_VARS)
-LOCAL_MODULE := android-support-compat-honeycomb
-LOCAL_SDK_VERSION := 11
-LOCAL_SRC_FILES := $(call all-java-files-under, honeycomb)
-LOCAL_STATIC_JAVA_LIBRARIES := android-support-compat-gingerbread
-LOCAL_JAVA_LANGUAGE_VERSION := 1.7
-include $(BUILD_STATIC_JAVA_LIBRARY)
-
-# -----------------------------------------------------------------------
-
-# A helper sub-library that makes direct use of Honeycomb MR1 APIs.
-include $(CLEAR_VARS)
-LOCAL_MODULE := android-support-compat-honeycomb-mr1
-LOCAL_SDK_VERSION := 12
-LOCAL_SRC_FILES := $(call all-java-files-under, honeycomb_mr1)
-LOCAL_STATIC_JAVA_LIBRARIES := android-support-compat-honeycomb
-LOCAL_JAVA_LANGUAGE_VERSION := 1.7
-include $(BUILD_STATIC_JAVA_LIBRARY)
-
-# -----------------------------------------------------------------------
-
-# A helper sub-library that makes direct use of Honeycomb MR2 APIs.
-include $(CLEAR_VARS)
-LOCAL_MODULE := android-support-compat-honeycomb-mr2
-LOCAL_SDK_VERSION := 13
-LOCAL_SRC_FILES := $(call all-java-files-under, honeycomb_mr2)
-LOCAL_STATIC_JAVA_LIBRARIES := android-support-compat-honeycomb-mr1
-LOCAL_JAVA_LANGUAGE_VERSION := 1.7
-include $(BUILD_STATIC_JAVA_LIBRARY)
-
-# -----------------------------------------------------------------------
-
-# A helper sub-library that makes direct use of Ice Cream Sandwich APIs.
-include $(CLEAR_VARS)
-LOCAL_MODULE := android-support-compat-ics
-LOCAL_SDK_VERSION := 14
-LOCAL_SRC_FILES := $(call all-java-files-under, ics)
-LOCAL_STATIC_JAVA_LIBRARIES := android-support-compat-honeycomb-mr2
-LOCAL_JAVA_LANGUAGE_VERSION := 1.7
-include $(BUILD_STATIC_JAVA_LIBRARY)
-
-# -----------------------------------------------------------------------
-
-# A helper sub-library that makes direct use of Ice Cream Sandwich MR1 APIs.
-include $(CLEAR_VARS)
-LOCAL_MODULE := android-support-compat-ics-mr1
-LOCAL_SDK_VERSION := 15
-LOCAL_SRC_FILES := $(call all-java-files-under, ics-mr1)
-LOCAL_STATIC_JAVA_LIBRARIES := android-support-compat-ics
-LOCAL_JAVA_LANGUAGE_VERSION := 1.7
-include $(BUILD_STATIC_JAVA_LIBRARY)
-
-# -----------------------------------------------------------------------
-
-# A helper sub-library that makes direct use of JellyBean APIs.
-include $(CLEAR_VARS)
-LOCAL_MODULE := android-support-compat-jellybean
-LOCAL_SDK_VERSION := 16
-LOCAL_SRC_FILES := $(call all-java-files-under, jellybean)
-LOCAL_STATIC_JAVA_LIBRARIES := android-support-compat-ics-mr1
-LOCAL_JAVA_LANGUAGE_VERSION := 1.7
-include $(BUILD_STATIC_JAVA_LIBRARY)
-
-# -----------------------------------------------------------------------
-
-# A helper sub-library that makes direct use of JellyBean MR1 APIs.
-include $(CLEAR_VARS)
-LOCAL_MODULE := android-support-compat-jellybean-mr1
-LOCAL_SDK_VERSION := 17
-LOCAL_SRC_FILES := $(call all-java-files-under, jellybean-mr1)
-LOCAL_STATIC_JAVA_LIBRARIES := android-support-compat-jellybean
-LOCAL_JAVA_LANGUAGE_VERSION := 1.7
-include $(BUILD_STATIC_JAVA_LIBRARY)
-
-# -----------------------------------------------------------------------
-
-# A helper sub-library that makes direct use of JellyBean MR2 APIs.
-include $(CLEAR_VARS)
-LOCAL_MODULE := android-support-compat-jellybean-mr2
-LOCAL_SDK_VERSION := 18
-LOCAL_SRC_FILES := $(call all-java-files-under, jellybean-mr2)
-LOCAL_STATIC_JAVA_LIBRARIES := android-support-compat-jellybean-mr1
-LOCAL_JAVA_LANGUAGE_VERSION := 1.7
-include $(BUILD_STATIC_JAVA_LIBRARY)
-
-# -----------------------------------------------------------------------
-
-# A helper sub-library that makes direct use of KitKat APIs.
-include $(CLEAR_VARS)
-LOCAL_MODULE := android-support-compat-kitkat
-LOCAL_SDK_VERSION := 19
-LOCAL_SRC_FILES := $(call all-java-files-under, kitkat)
-LOCAL_STATIC_JAVA_LIBRARIES := android-support-compat-jellybean-mr2
-LOCAL_JAVA_LANGUAGE_VERSION := 1.7
-include $(BUILD_STATIC_JAVA_LIBRARY)
-
-# -----------------------------------------------------------------------
-
-# A helper sub-library that makes direct use of V20 APIs.
-include $(CLEAR_VARS)
-LOCAL_MODULE := android-support-compat-api20
-LOCAL_SDK_VERSION := 20
-LOCAL_SRC_FILES := $(call all-java-files-under, api20)
-LOCAL_STATIC_JAVA_LIBRARIES := android-support-compat-kitkat
-LOCAL_JAVA_LANGUAGE_VERSION := 1.7
-include $(BUILD_STATIC_JAVA_LIBRARY)
-
-# -----------------------------------------------------------------------
-
-# A helper sub-library that makes direct use of Lollipop APIs.
-include $(CLEAR_VARS)
-LOCAL_MODULE := android-support-compat-api21
-LOCAL_SDK_VERSION := 21
-LOCAL_SRC_FILES := $(call all-java-files-under, api21)
-LOCAL_STATIC_JAVA_LIBRARIES := android-support-compat-api20
-LOCAL_JAVA_LANGUAGE_VERSION := 1.7
-include $(BUILD_STATIC_JAVA_LIBRARY)
-
-# -----------------------------------------------------------------------
-
-# A helper sub-library that makes direct use of V22 APIs.
-include $(CLEAR_VARS)
-LOCAL_MODULE := android-support-compat-api22
-LOCAL_SDK_VERSION := 22
-LOCAL_SRC_FILES := $(call all-java-files-under, api22)
-LOCAL_STATIC_JAVA_LIBRARIES := android-support-compat-api21
-LOCAL_JAVA_LANGUAGE_VERSION := 1.7
-include $(BUILD_STATIC_JAVA_LIBRARY)
-
-# -----------------------------------------------------------------------
-
-# A helper sub-library that makes direct use of V23 APIs.
-include $(CLEAR_VARS)
-LOCAL_MODULE := android-support-compat-api23
-LOCAL_SDK_VERSION := 23
-LOCAL_SRC_FILES := $(call all-java-files-under, api23)
-LOCAL_STATIC_JAVA_LIBRARIES := android-support-compat-api22
-LOCAL_JAVA_LANGUAGE_VERSION := 1.7
-include $(BUILD_STATIC_JAVA_LIBRARY)
-
-# -----------------------------------------------------------------------
-
-# A helper sub-library that makes direct use of V24 APIs.
-include $(CLEAR_VARS)
-LOCAL_MODULE := android-support-compat-api24
-LOCAL_SDK_VERSION := 24
-LOCAL_SRC_FILES := $(call all-java-files-under, api24)
-LOCAL_STATIC_JAVA_LIBRARIES := android-support-compat-api23
-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-compat
+#
+# in their makefiles to include the resources and their dependencies in their package.
 include $(CLEAR_VARS)
 LOCAL_USE_AAPT2 := true
 LOCAL_MODULE := android-support-compat
-LOCAL_SDK_VERSION := 9
-LOCAL_AIDL_INCLUDES := frameworks/support/compat/java
-LOCAL_SRC_FILES := $(call all-java-files-under, java) \
-    $(call all-Iaidl-files-under, java)
+LOCAL_SDK_VERSION := $(SUPPORT_CURRENT_SDK_VERSION)
+LOCAL_AIDL_INCLUDES := $(LOCAL_PATH)/java
+LOCAL_SRC_FILES := \
+    $(call all-java-files-under,gingerbread) \
+    $(call all-java-files-under,honeycomb) \
+    $(call all-java-files-under,honeycomb_mr1) \
+    $(call all-java-files-under,honeycomb_mr2) \
+    $(call all-java-files-under,ics) \
+    $(call all-java-files-under,ics-mr1) \
+    $(call all-java-files-under,jellybean) \
+    $(call all-java-files-under,jellybean-mr1) \
+    $(call all-java-files-under,jellybean-mr2) \
+    $(call all-java-files-under,kitkat) \
+    $(call all-java-files-under,api20) \
+    $(call all-java-files-under,api21) \
+    $(call all-java-files-under,api22) \
+    $(call all-java-files-under,api23) \
+    $(call all-java-files-under,api24) \
+    $(call all-java-files-under,java) \
+    $(call all-Iaidl-files-under,java)
 LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res
-LOCAL_STATIC_JAVA_LIBRARIES += android-support-compat-api24
+LOCAL_SHARED_ANDROID_LIBRARIES := \
+    android-support-annotations
 LOCAL_JAR_EXCLUDE_FILES := none
 LOCAL_JAVA_LANGUAGE_VERSION := 1.7
+LOCAL_AAPT_FLAGS := --add-javadoc-annotation doconly
 include $(BUILD_STATIC_JAVA_LIBRARY)
diff --git a/compat/build.gradle b/compat/build.gradle
index cd9e693..2f43b54 100644
--- a/compat/build.gradle
+++ b/compat/build.gradle
@@ -1,9 +1,8 @@
 apply plugin: 'com.android.library'
 archivesBaseName = 'support-compat'
 
-
-createApiSourceSets(project, gradle.ext.studioCompat.modules.compat.apiTargets)
 dependencies {
+    compile project(':support-annotations')
     androidTestCompile ("com.android.support.test:runner:${project.rootProject.ext.testRunnerVersion}") {
         exclude module: 'support-annotations'
     }
@@ -18,22 +17,35 @@
 
 sourceCompatibility = JavaVersion.VERSION_1_7
 targetCompatibility = JavaVersion.VERSION_1_7
-setApiModuleDependencies(project, dependencies, gradle.ext.studioCompat.modules.compat.dependencies)
 
 android {
-    compileSdkVersion 9
+    compileSdkVersion project.ext.currentSdk
 
     defaultConfig {
         minSdkVersion 9
-        // TODO: get target from branch
-        //targetSdkVersion 19
-
         testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
     }
 
     sourceSets {
         main.manifest.srcFile 'AndroidManifest.xml'
-        main.java.srcDirs = ['java']
+        main.java.srcDirs = [
+                'gingerbread',
+                'honeycomb',
+                'honeycomb_mr1',
+                'honeycomb_mr2',
+                'ics',
+                'ics-mr1',
+                'jellybean',
+                'jellybean-mr1',
+                'jellybean-mr2',
+                'kitkat',
+                'api20',
+                'api21',
+                'api22',
+                'api23',
+                'api24',
+                'java'
+        ]
         main.aidl.srcDirs = ['java']
 
         androidTest.setRoot('tests')
@@ -89,11 +101,6 @@
         exclude('android/service/media/**')
     }
 
-    project.ext.allSS.each { ss ->
-        javadocTask.source ss.java
-        sourcesJarTask.from ss.java.srcDirs
-    }
-
     artifacts.add('archives', javadocJarTask);
     artifacts.add('archives', sourcesJarTask);
 }
diff --git a/compat/gingerbread/android/support/v4/app/NotificationCompatBase.java b/compat/gingerbread/android/support/v4/app/NotificationCompatBase.java
index e4d0f2b..7c2820c 100644
--- a/compat/gingerbread/android/support/v4/app/NotificationCompatBase.java
+++ b/compat/gingerbread/android/support/v4/app/NotificationCompatBase.java
@@ -16,19 +16,23 @@
 
 package android.support.v4.app;
 
+import static android.support.annotation.RestrictTo.Scope.GROUP_ID;
+
 import android.app.Notification;
 import android.app.PendingIntent;
 import android.content.Context;
 import android.os.Bundle;
 import android.support.annotation.RestrictTo;
 
-import static android.support.annotation.RestrictTo.Scope.GROUP_ID;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
 
 /**
  * @hide
  */
 @RestrictTo(GROUP_ID)
 public class NotificationCompatBase {
+    private static Method sSetLatestEventInfo;
 
     public static abstract class Action {
         public abstract int getIcon();
@@ -66,7 +70,26 @@
     public static Notification add(Notification notification, Context context,
             CharSequence contentTitle, CharSequence contentText, PendingIntent contentIntent,
             PendingIntent fullScreenIntent) {
-        notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent);
+        if (sSetLatestEventInfo == null) {
+            try {
+                sSetLatestEventInfo = Notification.class.getMethod("setLatestEventInfo",
+                        Context.class, CharSequence.class, CharSequence.class, PendingIntent.class);
+            } catch (NoSuchMethodException e) {
+                // This method was @removed, so it must exist on later
+                // versions even if it's not in public API.
+                throw new RuntimeException(e);
+            }
+        }
+
+        try {
+            sSetLatestEventInfo.invoke(notification, context,
+                    contentTitle, contentText, contentIntent);
+        } catch (IllegalAccessException | InvocationTargetException e) {
+            // This method was @removed, so it must be invokable on later
+            // versions even if it's not in public API.
+            throw new RuntimeException(e);
+        }
+
         notification.fullScreenIntent = fullScreenIntent;
         return notification;
     }
diff --git a/core-ui/Android.mk b/core-ui/Android.mk
index 3765b04..bdad9f9 100644
--- a/core-ui/Android.mk
+++ b/core-ui/Android.mk
@@ -14,63 +14,29 @@
 
 LOCAL_PATH := $(call my-dir)
 
-# A helper sub-library that makes direct use of Honeycomb APIs.
-include $(CLEAR_VARS)
-LOCAL_MODULE := android-support-core-ui-honeycomb
-LOCAL_SDK_VERSION := 11
-LOCAL_SRC_FILES := $(call all-java-files-under, honeycomb)
-LOCAL_STATIC_JAVA_LIBRARIES := \
-    android-support-annotations \
-    android-support-compat
-LOCAL_JAVA_LANGUAGE_VERSION := 1.7
-include $(BUILD_STATIC_JAVA_LIBRARY)
-
-# -----------------------------------------------------------------------
-
-# A helper sub-library that makes direct use of Ice Cream Sandwich APIs.
-include $(CLEAR_VARS)
-LOCAL_MODULE := android-support-core-ui-ics
-LOCAL_SDK_VERSION := 14
-LOCAL_SRC_FILES := $(call all-java-files-under, ics)
-LOCAL_STATIC_JAVA_LIBRARIES := android-support-core-ui-honeycomb
-LOCAL_JAVA_LANGUAGE_VERSION := 1.7
-include $(BUILD_STATIC_JAVA_LIBRARY)
-
-# -----------------------------------------------------------------------
-
-# A helper sub-library that makes direct use of JellyBean MR2 APIs.
-include $(CLEAR_VARS)
-LOCAL_MODULE := android-support-core-ui-jellybean-mr2
-LOCAL_SDK_VERSION := 18
-LOCAL_SRC_FILES := $(call all-java-files-under, jellybean-mr2)
-LOCAL_STATIC_JAVA_LIBRARIES := android-support-core-ui-ics
-LOCAL_JAVA_LANGUAGE_VERSION := 1.7
-include $(BUILD_STATIC_JAVA_LIBRARY)
-
-# -----------------------------------------------------------------------
-
-# A helper sub-library that makes direct use of Lollipop APIs.
-include $(CLEAR_VARS)
-LOCAL_MODULE := android-support-core-ui-api21
-LOCAL_SDK_VERSION := 21
-LOCAL_SRC_FILES := $(call all-java-files-under, api21)
-LOCAL_STATIC_JAVA_LIBRARIES := android-support-core-ui-jellybean-mr2
-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-core-ui \
+#       android-support-compat
+#
+# in their makefiles to include the resources and their dependencies in their package.
 include $(CLEAR_VARS)
 LOCAL_USE_AAPT2 := true
 LOCAL_MODULE := android-support-core-ui
-LOCAL_SDK_VERSION := 9
-LOCAL_SRC_FILES := $(call all-java-files-under, java)
+LOCAL_SDK_VERSION := $(SUPPORT_CURRENT_SDK_VERSION)
+LOCAL_SRC_FILES := \
+    $(call all-java-files-under,honeycomb) \
+    $(call all-java-files-under,ics) \
+    $(call all-java-files-under,jellybean-mr2) \
+    $(call all-java-files-under,api21) \
+    $(call all-java-files-under,java)
 LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res
-LOCAL_STATIC_JAVA_LIBRARIES := android-support-core-ui-api21
 LOCAL_SHARED_ANDROID_LIBRARIES := \
     android-support-compat \
     android-support-annotations
 LOCAL_JAR_EXCLUDE_FILES := none
 LOCAL_JAVA_LANGUAGE_VERSION := 1.7
+LOCAL_AAPT_FLAGS := --add-javadoc-annotation doconly
 include $(BUILD_STATIC_JAVA_LIBRARY)
diff --git a/core-ui/build.gradle b/core-ui/build.gradle
index 5ae0655..56afd5e 100644
--- a/core-ui/build.gradle
+++ b/core-ui/build.gradle
@@ -1,9 +1,8 @@
 apply plugin: 'com.android.library'
 archivesBaseName = 'support-core-ui'
 
-
-createApiSourceSets(project, gradle.ext.studioCompat.modules.coreui.apiTargets)
 dependencies {
+    compile project(':support-annotations')
     compile project(':support-compat')
     androidTestCompile ("com.android.support.test:runner:${project.rootProject.ext.testRunnerVersion}") {
         exclude module: 'support-annotations'
@@ -19,22 +18,24 @@
 
 sourceCompatibility = JavaVersion.VERSION_1_7
 targetCompatibility = JavaVersion.VERSION_1_7
-setApiModuleDependencies(project, dependencies, gradle.ext.studioCompat.modules.coreui.dependencies)
 
 android {
-    compileSdkVersion 9
+    compileSdkVersion project.ext.currentSdk
 
     defaultConfig {
         minSdkVersion 9
-        // TODO: get target from branch
-        //targetSdkVersion 19
-
         testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
     }
 
     sourceSets {
         main.manifest.srcFile 'AndroidManifest.xml'
-        main.java.srcDirs = ['java']
+        main.java.srcDirs = [
+                'honeycomb',
+                'ics',
+                'jellybean-mr2',
+                'api21',
+                'java'
+        ]
 
         androidTest.setRoot('tests')
         androidTest.java.srcDir 'tests/java'
@@ -93,11 +94,6 @@
         exclude('android/service/media/**')
     }
 
-    project.ext.allSS.each { ss ->
-        javadocTask.source ss.java
-        sourcesJarTask.from ss.java.srcDirs
-    }
-
     artifacts.add('archives', javadocJarTask);
     artifacts.add('archives', sourcesJarTask);
 }
diff --git a/core-utils/Android.mk b/core-utils/Android.mk
index add72db..d3f113e 100644
--- a/core-utils/Android.mk
+++ b/core-utils/Android.mk
@@ -14,107 +14,33 @@
 
 LOCAL_PATH := $(call my-dir)
 
-# A helper sub-library that makes direct use of Gingerbread APIs.
-include $(CLEAR_VARS)
-LOCAL_MODULE := android-support-core-utils-gingerbread
-LOCAL_SDK_VERSION := 9
-LOCAL_SRC_FILES := $(call all-java-files-under, gingerbread)
-LOCAL_STATIC_JAVA_LIBRARIES := \
-    android-support-annotations \
-    android-support-compat
-LOCAL_JAVA_LANGUAGE_VERSION := 1.7
-include $(BUILD_STATIC_JAVA_LIBRARY)
-
-# -----------------------------------------------------------------------
-
-# A helper sub-library that makes direct use of Honeycomb APIs.
-include $(CLEAR_VARS)
-LOCAL_MODULE := android-support-core-utils-honeycomb
-LOCAL_SDK_VERSION := 11
-LOCAL_SRC_FILES := $(call all-java-files-under, honeycomb)
-LOCAL_STATIC_JAVA_LIBRARIES := android-support-core-utils-gingerbread
-LOCAL_JAVA_LANGUAGE_VERSION := 1.7
-include $(BUILD_STATIC_JAVA_LIBRARY)
-
-# -----------------------------------------------------------------------
-
-# A helper sub-library that makes direct use of JellyBean APIs.
-include $(CLEAR_VARS)
-LOCAL_MODULE := android-support-core-utils-jellybean
-LOCAL_SDK_VERSION := 16
-LOCAL_SRC_FILES := $(call all-java-files-under, jellybean)
-LOCAL_STATIC_JAVA_LIBRARIES := android-support-core-utils-honeycomb
-LOCAL_JAVA_LANGUAGE_VERSION := 1.7
-include $(BUILD_STATIC_JAVA_LIBRARY)
-
-# -----------------------------------------------------------------------
-
-# A helper sub-library that makes direct use of KitKat APIs.
-include $(CLEAR_VARS)
-LOCAL_MODULE := android-support-core-utils-kitkat
-LOCAL_SDK_VERSION := 19
-LOCAL_SRC_FILES := $(call all-java-files-under, kitkat)
-LOCAL_STATIC_JAVA_LIBRARIES := android-support-core-utils-jellybean
-LOCAL_JAVA_LANGUAGE_VERSION := 1.7
-include $(BUILD_STATIC_JAVA_LIBRARY)
-
-# -----------------------------------------------------------------------
-
-# A helper sub-library that makes direct use of V20 APIs.
-include $(CLEAR_VARS)
-LOCAL_MODULE := android-support-core-utils-api20
-LOCAL_SDK_VERSION := 20
-LOCAL_SRC_FILES := $(call all-java-files-under, api20)
-LOCAL_STATIC_JAVA_LIBRARIES := android-support-core-utils-kitkat
-LOCAL_JAVA_LANGUAGE_VERSION := 1.7
-include $(BUILD_STATIC_JAVA_LIBRARY)
-
-# -----------------------------------------------------------------------
-
-# A helper sub-library that makes direct use of Lollipop APIs.
-include $(CLEAR_VARS)
-LOCAL_MODULE := android-support-core-utils-api21
-LOCAL_SDK_VERSION := 21
-LOCAL_SRC_FILES := $(call all-java-files-under, api21)
-LOCAL_STATIC_JAVA_LIBRARIES := android-support-core-utils-api20
-LOCAL_JAVA_LANGUAGE_VERSION := 1.7
-include $(BUILD_STATIC_JAVA_LIBRARY)
-
-# -----------------------------------------------------------------------
-
-# A helper sub-library that makes direct use of V23 APIs.
-include $(CLEAR_VARS)
-LOCAL_MODULE := android-support-core-utils-api23
-LOCAL_SDK_VERSION := 23
-LOCAL_SRC_FILES := $(call all-java-files-under, api23)
-LOCAL_STATIC_JAVA_LIBRARIES := android-support-core-utils-api21
-LOCAL_JAVA_LANGUAGE_VERSION := 1.7
-include $(BUILD_STATIC_JAVA_LIBRARY)
-
-# -----------------------------------------------------------------------
-
-# A helper sub-library that makes direct use of V24 APIs.
-include $(CLEAR_VARS)
-LOCAL_MODULE := android-support-core-utils-api24
-LOCAL_SDK_VERSION := 24
-LOCAL_SRC_FILES := $(call all-java-files-under, api24)
-LOCAL_STATIC_JAVA_LIBRARIES := android-support-core-utils-api23
-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-core-utils \
+#       android-support-compat
+#
+# in their makefiles to include the resources and their dependencies in their package.
 include $(CLEAR_VARS)
 LOCAL_USE_AAPT2 := true
 LOCAL_MODULE := android-support-core-utils
-LOCAL_SDK_VERSION := 9
-LOCAL_SRC_FILES := $(call all-java-files-under, java)
+LOCAL_SDK_VERSION := $(SUPPORT_CURRENT_SDK_VERSION)
+LOCAL_SRC_FILES := \
+    $(call all-java-files-under,gingerbread) \
+    $(call all-java-files-under,honeycomb) \
+    $(call all-java-files-under,jellybean) \
+    $(call all-java-files-under,kitkat) \
+    $(call all-java-files-under,api20) \
+    $(call all-java-files-under,api21) \
+    $(call all-java-files-under,api23) \
+    $(call all-java-files-under,api24) \
+    $(call all-java-files-under,java)
 LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res
-LOCAL_STATIC_JAVA_LIBRARIES += android-support-core-utils-api24
 LOCAL_SHARED_ANDROID_LIBRARIES := \
     android-support-compat \
     android-support-annotations
 LOCAL_JAR_EXCLUDE_FILES := none
 LOCAL_JAVA_LANGUAGE_VERSION := 1.7
+LOCAL_AAPT_FLAGS := --add-javadoc-annotation doconly
 include $(BUILD_STATIC_JAVA_LIBRARY)
diff --git a/core-utils/build.gradle b/core-utils/build.gradle
index f6ceb14..97325a1 100644
--- a/core-utils/build.gradle
+++ b/core-utils/build.gradle
@@ -1,9 +1,8 @@
 apply plugin: 'com.android.library'
 archivesBaseName = 'support-core-utils'
 
-
-createApiSourceSets(project, gradle.ext.studioCompat.modules.coreutils.apiTargets)
 dependencies {
+    compile project(':support-annotations')
     compile project(':support-compat')
     androidTestCompile ("com.android.support.test:runner:${project.rootProject.ext.testRunnerVersion}") {
         exclude module: 'support-annotations'
@@ -17,24 +16,28 @@
     testCompile 'junit:junit:4.12'
 }
 
-sourceCompatibility = JavaVersion.VERSION_1_7
-targetCompatibility = JavaVersion.VERSION_1_7
-setApiModuleDependencies(project, dependencies, gradle.ext.studioCompat.modules.coreutils.dependencies)
-
 android {
-    compileSdkVersion 9
+    compileSdkVersion project.ext.currentSdk
 
     defaultConfig {
         minSdkVersion 9
-        // TODO: get target from branch
-        //targetSdkVersion 19
 
         testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
     }
 
     sourceSets {
         main.manifest.srcFile 'AndroidManifest.xml'
-        main.java.srcDirs = ['java']
+        main.java.srcDirs = [
+                'gingerbread',
+                'honeycomb',
+                'jellybean',
+                'kitkat',
+                'api20',
+                'api21',
+                'api23',
+                'api24',
+                'java'
+        ]
 
         androidTest.setRoot('tests')
         androidTest.java.srcDir 'tests/java'
@@ -88,11 +91,6 @@
         exclude('android/service/media/**')
     }
 
-    project.ext.allSS.each { ss ->
-        javadocTask.source ss.java
-        sourcesJarTask.from ss.java.srcDirs
-    }
-
     artifacts.add('archives', javadocJarTask);
     artifacts.add('archives', sourcesJarTask);
 }
diff --git a/customtabs/Android.mk b/customtabs/Android.mk
index 50e6dbc..cfd9971 100644
--- a/customtabs/Android.mk
+++ b/customtabs/Android.mk
@@ -15,16 +15,25 @@
 LOCAL_PATH := $(call my-dir)
 
 # 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.
+# Applications that use this library must specify
+#
+#   LOCAL_STATIC_ANDROID_LIBRARIES := \
+#       android-support-customtabs \
+#       android-support-compat
+#
+# in their makefiles to include the resources and their dependencies in their package.
 include $(CLEAR_VARS)
+LOCAL_USE_AAPT2 := true
 LOCAL_MODULE := android-support-customtabs
 LOCAL_SDK_VERSION := $(SUPPORT_CURRENT_SDK_VERSION)
 LOCAL_AIDL_INCLUDES := $LOCAL_PATH/src
-LOCAL_SRC_FILES := $(call all-java-files-under, src) \
-    $(call all-Iaidl-files-under, src)
-LOCAL_JAVA_LIBRARIES := android-support-annotations \
-android-support-compat
+LOCAL_SRC_FILES := \
+    $(call all-java-files-under,src) \
+    $(call all-Iaidl-files-under,src)
+LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res
+LOCAL_SHARED_ANDROID_LIBRARIES := \
+    android-support-annotations \
+    android-support-compat
 LOCAL_JAVA_LANGUAGE_VERSION := 1.7
+LOCAL_AAPT_FLAGS := --add-javadoc-annotation doconly
 include $(BUILD_STATIC_JAVA_LIBRARY)
diff --git a/design/Android.mk b/design/Android.mk
index 3217915..b3bc846 100644
--- a/design/Android.mk
+++ b/design/Android.mk
@@ -14,158 +14,38 @@
 
 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_JAR_EXCLUDE_FILES := none
-LOCAL_JAVA_LANGUAGE_VERSION := 1.7
-include $(BUILD_STATIC_JAVA_LIBRARY)
-
-# A helper sub-library to resolve cyclic dependencies between src and the platform dependent
-# implementations
-include $(CLEAR_VARS)
-LOCAL_MODULE := android-support-design-base
-LOCAL_SDK_VERSION := 9
-LOCAL_SRC_FILES := $(call all-java-files-under, base)
-LOCAL_JAVA_LIBRARIES := \
-    android-support-design-res \
-    android-support-compat \
-    android-support-core-utils \
-    android-support-core-ui \
-    android-support-fragment \
-    android-support-v7-appcompat \
-    android-support-v7-recyclerview
-LOCAL_JAVA_LANGUAGE_VERSION := 1.7
-include $(BUILD_STATIC_JAVA_LIBRARY)
-
-# A helper sub-library that makes direct use of Gingerbread APIs
-include $(CLEAR_VARS)
-LOCAL_MODULE := android-support-design-gingerbread
-LOCAL_SDK_VERSION := 9
-LOCAL_SRC_FILES := $(call all-java-files-under, gingerbread)
-LOCAL_STATIC_JAVA_LIBRARIES := android-support-design-base
-LOCAL_JAVA_LIBRARIES := \
-    android-support-design-res \
-    android-support-compat \
-    android-support-core-utils \
-    android-support-core-ui \
-    android-support-fragment \
-    android-support-v7-appcompat \
-    android-support-v7-recyclerview
-LOCAL_JAVA_LANGUAGE_VERSION := 1.7
-include $(BUILD_STATIC_JAVA_LIBRARY)
-
-# A helper sub-library that makes direct use of Honeycomb APIs
-include $(CLEAR_VARS)
-LOCAL_MODULE := android-support-design-honeycomb
-LOCAL_SDK_VERSION := 11
-LOCAL_SRC_FILES := $(call all-java-files-under, honeycomb)
-LOCAL_STATIC_JAVA_LIBRARIES := android-support-design-gingerbread
-LOCAL_JAVA_LIBRARIES := \
-    android-support-design-res \
-    android-support-compat \
-    android-support-core-utils \
-    android-support-core-ui \
-    android-support-fragment \
-    android-support-v7-appcompat \
-    android-support-v7-recyclerview
-LOCAL_JAVA_LANGUAGE_VERSION := 1.7
-include $(BUILD_STATIC_JAVA_LIBRARY)
-
-# A helper sub-library that makes direct use of Honeycomb MR1 APIs
-include $(CLEAR_VARS)
-LOCAL_MODULE := android-support-design-honeycomb-mr1
-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 \
-    android-support-compat \
-    android-support-core-utils \
-    android-support-core-ui \
-    android-support-fragment \
-    android-support-v7-appcompat \
-    android-support-v7-recyclerview
-LOCAL_JAVA_LANGUAGE_VERSION := 1.7
-include $(BUILD_STATIC_JAVA_LIBRARY)
-
-# A helper sub-library that makes direct use of ICS APIs
-include $(CLEAR_VARS)
-LOCAL_MODULE := android-support-design-ics
-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 \
-    android-support-compat \
-    android-support-core-utils \
-    android-support-core-ui \
-    android-support-fragment \
-    android-support-v7-appcompat \
-    android-support-v7-recyclerview \
-    android-support-transition
-LOCAL_JAVA_LANGUAGE_VERSION := 1.7
-include $(BUILD_STATIC_JAVA_LIBRARY)
-
-# A helper sub-library that makes direct use of Lollipop APIs
-include $(CLEAR_VARS)
-LOCAL_MODULE := android-support-design-lollipop
-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 \
-    android-support-compat \
-    android-support-core-utils \
-    android-support-core-ui \
-    android-support-fragment \
-    android-support-v7-appcompat \
-    android-support-v7-recyclerview \
-    android-support-transition
-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-design \
+#       android-support-transition \
 #       android-support-v7-appcompat \
 #       android-support-v7-recyclerview \
-#       android-support-compat \
-#       android-support-core-utils \
-#       android-support-core-ui \
-#       android-support-fragment
+#       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-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_SRC_FILES := \
+    $(call all-java-files-under,base) \
+    $(call all-java-files-under,gingerbread) \
+    $(call all-java-files-under,honeycomb) \
+    $(call all-java-files-under,honeycomb-mr1) \
+    $(call all-java-files-under,ics) \
+    $(call all-java-files-under,lollipop) \
+    $(call all-java-files-under,src)
+LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res
 LOCAL_SHARED_ANDROID_LIBRARIES := \
-    $(resource_libs) \
-    android-support-compat \
-    android-support-core-utils \
-    android-support-core-ui \
-    android-support-fragment
-LOCAL_JAR_EXCLUDE_FILES := none
+    android-support-transition \
+    android-support-v7-appcompat \
+    android-support-v7-recyclerview \
+    android-support-v4 \
+    android-support-annotations
 LOCAL_JAVA_LANGUAGE_VERSION := 1.7
-LOCAL_AAPT_FLAGS := --add-javadoc-annotation doconly
+LOCAL_AAPT_FLAGS := \
+    --no-version-vectors \
+    --add-javadoc-annotation doconly
 include $(BUILD_STATIC_JAVA_LIBRARY)
diff --git a/design/build.gradle b/design/build.gradle
index 577b047..1f35a60 100644
--- a/design/build.gradle
+++ b/design/build.gradle
@@ -3,10 +3,7 @@
 archivesBaseName = 'design'
 
 dependencies {
-    compile project(':support-compat')
-    compile project(':support-core-utils')
-    compile project(':support-core-ui')
-    compile project(':support-fragment')
+    compile project(':support-v4')
     compile project(':support-appcompat-v7')
     compile project(':support-recyclerview-v7')
     compile project(':support-transition')
@@ -38,9 +35,19 @@
 
     sourceSets {
         main.manifest.srcFile 'AndroidManifest.xml'
-        main.java.srcDirs = ['base', 'gingerbread', 'honeycomb', 'honeycomb-mr1', 'ics', 'lollipop', 'src']
-        main.res.srcDirs 'res', 'res-public'
-        main.assets.srcDir 'assets'
+        main.java.srcDirs = [
+                'base',
+                'gingerbread',
+                'honeycomb',
+                'honeycomb-mr1',
+                'ics',
+                'lollipop',
+                'src'
+        ]
+        main.res.srcDirs = [
+                'res',
+                'res-public'
+        ]
         main.resources.srcDir 'src'
 
         androidTest.setRoot('tests')
diff --git a/fragment/Android.mk b/fragment/Android.mk
index e5cb644..a41b0c2 100644
--- a/fragment/Android.mk
+++ b/fragment/Android.mk
@@ -14,81 +14,34 @@
 
 LOCAL_PATH := $(call my-dir)
 
-# A helper sub-library that makes direct use of Gingerbread APIs.
-include $(CLEAR_VARS)
-LOCAL_MODULE := android-support-fragment-gingerbread
-LOCAL_SDK_VERSION := 9
-LOCAL_SRC_FILES := $(call all-java-files-under, gingerbread)
-LOCAL_JAVA_LIBRARIES := \
-    android-support-annotations \
-    android-support-compat \
-    android-support-core-utils \
-    android-support-media-compat \
-    android-support-core-ui
-LOCAL_JAVA_LANGUAGE_VERSION := 1.7
-include $(BUILD_STATIC_JAVA_LIBRARY)
-
-# -----------------------------------------------------------------------
-
-# A helper sub-library that makes direct use of Honeycomb APIs.
-include $(CLEAR_VARS)
-LOCAL_MODULE := android-support-fragment-honeycomb
-LOCAL_SDK_VERSION := 11
-LOCAL_SRC_FILES := $(call all-java-files-under, honeycomb)
-LOCAL_STATIC_JAVA_LIBRARIES := android-support-fragment-gingerbread
-LOCAL_JAVA_LANGUAGE_VERSION := 1.7
-include $(BUILD_STATIC_JAVA_LIBRARY)
-
-# -----------------------------------------------------------------------
-
-# A helper sub-library that makes direct use of JellyBean APIs.
-include $(CLEAR_VARS)
-LOCAL_MODULE := android-support-fragment-jellybean
-LOCAL_SDK_VERSION := 16
-LOCAL_SRC_FILES := $(call all-java-files-under, jellybean)
-LOCAL_STATIC_JAVA_LIBRARIES := android-support-fragment-honeycomb
-LOCAL_JAVA_LIBRARIES := \
-    android-support-annotations \
-    android-support-compat \
-    android-support-media-compat \
-    android-support-core-ui \
-    android-support-core-utils
-LOCAL_JAVA_LANGUAGE_VERSION := 1.7
-include $(BUILD_STATIC_JAVA_LIBRARY)
-
-# -----------------------------------------------------------------------
-
-# A helper sub-library that makes direct use of Lollipop APIs.
-include $(CLEAR_VARS)
-LOCAL_MODULE := android-support-fragment-api21
-LOCAL_SDK_VERSION := 21
-LOCAL_SRC_FILES := $(call all-java-files-under, api21)
-LOCAL_STATIC_JAVA_LIBRARIES := android-support-fragment-jellybean
-LOCAL_JAVA_LIBRARIES := \
-    android-support-annotations \
-    android-support-compat \
-    android-support-media-compat \
-    android-support-core-ui \
-    android-support-core-utils
-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-fragment \
+#       android-support-compat \
+#       android-support-media-compat \
+#       android-support-core-ui \
+#       android-support-core-utils
+#
+# in their makefiles to include the resources and their dependencies in their package.
 include $(CLEAR_VARS)
 LOCAL_USE_AAPT2 := true
 LOCAL_MODULE := android-support-fragment
-LOCAL_SDK_VERSION := 9
-LOCAL_SRC_FILES := $(call all-java-files-under, java)
+LOCAL_SDK_VERSION := $(SUPPORT_CURRENT_SDK_VERSION)
+LOCAL_SRC_FILES := \
+    $(call all-java-files-under, gingerbread) \
+    $(call all-java-files-under, honeycomb) \
+    $(call all-java-files-under, jellybean) \
+    $(call all-java-files-under, api21) \
+    $(call all-java-files-under, java)
 LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res
-LOCAL_STATIC_JAVA_LIBRARIES := android-support-fragment-api21
-LOCAL_JAVA_LIBRARIES := \
-    android-support-annotations \
+LOCAL_SHARED_ANDROID_LIBRARIES := \
     android-support-compat \
-    android-support-media-compat \
     android-support-core-ui \
-    android-support-core-utils
+    android-support-core-utils \
+    android-support-media-compat \
+    android-support-annotations
 LOCAL_JAR_EXCLUDE_FILES := none
 LOCAL_JAVA_LANGUAGE_VERSION := 1.7
 LOCAL_AAPT_FLAGS := --add-javadoc-annotation doconly
diff --git a/fragment/build.gradle b/fragment/build.gradle
index 592c856..0a862d4 100644
--- a/fragment/build.gradle
+++ b/fragment/build.gradle
@@ -1,8 +1,6 @@
 apply plugin: 'com.android.library'
 archivesBaseName = 'support-fragment'
 
-
-createApiSourceSets(project, gradle.ext.studioCompat.modules.fragment.apiTargets)
 dependencies {
     compile project(':support-compat')
     compile project(':support-media-compat')
@@ -22,22 +20,25 @@
 
 sourceCompatibility = JavaVersion.VERSION_1_7
 targetCompatibility = JavaVersion.VERSION_1_7
-setApiModuleDependencies(project, dependencies, gradle.ext.studioCompat.modules.fragment.dependencies)
 
 android {
-    compileSdkVersion 9
+    compileSdkVersion project.ext.currentSdk
 
     defaultConfig {
         minSdkVersion 9
-        // TODO: get target from branch
-        //targetSdkVersion 19
 
         testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
     }
 
     sourceSets {
         main.manifest.srcFile 'AndroidManifest.xml'
-        main.java.srcDirs = ['java']
+        main.java.srcDirs = [
+                'gingerbread',
+                'honeycomb',
+                'jellybean',
+                'api21',
+                'java'
+        ]
 
         androidTest.setRoot('tests')
         androidTest.java.srcDir 'tests/java'
@@ -92,11 +93,6 @@
         exclude('android/service/media/**')
     }
 
-    project.ext.allSS.each { ss ->
-        javadocTask.source ss.java
-        sourcesJarTask.from ss.java.srcDirs
-    }
-
     artifacts.add('archives', javadocJarTask);
     artifacts.add('archives', sourcesJarTask);
 }
diff --git a/graphics/drawable/Android.mk b/graphics/drawable/Android.mk
index 61039fb..f58493b 100644
--- a/graphics/drawable/Android.mk
+++ b/graphics/drawable/Android.mk
@@ -20,13 +20,17 @@
 #
 # ---------------------------------------------
 include $(CLEAR_VARS)
+LOCAL_USE_AAPT2 := true
 LOCAL_MODULE := android-support-vectordrawable
 LOCAL_SDK_VERSION := $(SUPPORT_CURRENT_SDK_VERSION)
 LOCAL_SRC_FILES := $(call all-java-files-under, static/src)
-
-LOCAL_JAVA_LIBRARIES := android-support-compat
-
+LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/static/res
+LOCAL_MANIFEST_FILE := static/AndroidManifest.xml
+LOCAL_SHARED_ANDROID_LIBRARIES := \
+    android-support-compat \
+    android-support-annotations
 LOCAL_JAVA_LANGUAGE_VERSION := 1.7
+LOCAL_AAPT_FLAGS := --add-javadoc-annotation doconly
 include $(BUILD_STATIC_JAVA_LIBRARY)
 
 # ---------------------------------------------
@@ -35,12 +39,16 @@
 #
 # ---------------------------------------------
 include $(CLEAR_VARS)
+LOCAL_USE_AAPT2 := true
 LOCAL_MODULE := android-support-animatedvectordrawable
 LOCAL_SDK_VERSION := $(SUPPORT_CURRENT_SDK_VERSION)
 LOCAL_SRC_FILES := $(call all-java-files-under, animated/src)
-
-LOCAL_JAVA_LIBRARIES := android-support-compat android-support-vectordrawable
-
-LOCAL_AAPT_FLAGS := --no-version-vectors
+LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/animated/res
+LOCAL_MANIFEST_FILE := animated/AndroidManifest.xml
+LOCAL_SHARED_ANDROID_LIBRARIES := \
+    android-support-compat \
+    android-support-vectordrawable \
+    android-support-annotations
+LOCAL_AAPT_FLAGS := --no-version-vectors --add-javadoc-annotation doconly
 LOCAL_JAVA_LANGUAGE_VERSION := 1.7
 include $(BUILD_STATIC_JAVA_LIBRARY)
diff --git a/graphics/drawable/animated/api/current.txt b/graphics/drawable/animated/api/current.txt
deleted file mode 100644
index 1461956..0000000
--- a/graphics/drawable/animated/api/current.txt
+++ /dev/null
@@ -1,19 +0,0 @@
-package android.support.graphics.drawable {
-
-  public class AnimatedVectorDrawableCompat extends android.support.graphics.drawable.VectorDrawableCommon {
-    method public static android.support.graphics.drawable.AnimatedVectorDrawableCompat create(android.content.Context, int);
-    method public static android.support.graphics.drawable.AnimatedVectorDrawableCompat createFromXmlInner(android.content.Context, android.content.res.Resources, org.xmlpull.v1.XmlPullParser, android.util.AttributeSet, android.content.res.Resources.Theme) throws java.io.IOException, org.xmlpull.v1.XmlPullParserException;
-    method public void draw(android.graphics.Canvas);
-    method public int getOpacity();
-    method public boolean isRunning();
-    method public void setAlpha(int);
-    method public void setColorFilter(android.graphics.ColorFilter);
-    method public void start();
-    method public void stop();
-  }
-
-   abstract class VectorDrawableCommon extends android.graphics.drawable.Drawable {
-  }
-
-}
-
diff --git a/graphics/drawable/animated/api/removed.txt b/graphics/drawable/animated/api/removed.txt
deleted file mode 100644
index e69de29..0000000
--- a/graphics/drawable/animated/api/removed.txt
+++ /dev/null
diff --git a/graphics/drawable/animated/src/android/support/graphics/drawable/AnimatedVectorDrawableCompat.java b/graphics/drawable/animated/src/android/support/graphics/drawable/AnimatedVectorDrawableCompat.java
index 0b0522e..f5c6137 100644
--- a/graphics/drawable/animated/src/android/support/graphics/drawable/AnimatedVectorDrawableCompat.java
+++ b/graphics/drawable/animated/src/android/support/graphics/drawable/AnimatedVectorDrawableCompat.java
@@ -339,18 +339,6 @@
         mAnimatedVectorState.mVectorDrawable.setAutoMirrored(mirrored);
     }
 
-    /**
-     * Obtains styled attributes from the theme, if available, or unstyled
-     * resources if the theme is null.
-     */
-    static TypedArray obtainAttributes(
-            Resources res, Theme theme, AttributeSet set, int[] attrs) {
-        if (theme == null) {
-            return res.obtainAttributes(set, attrs);
-        }
-        return theme.obtainStyledAttributes(set, attrs, 0, 0);
-    }
-
     @Override
     public void inflate(Resources res, XmlPullParser parser, AttributeSet attrs, Theme theme)
             throws XmlPullParserException, IOException {
@@ -371,7 +359,7 @@
                 }
                 if (ANIMATED_VECTOR.equals(tagName)) {
                     final TypedArray a =
-                            obtainAttributes(res, theme, attrs,
+                            VectorDrawableCommon.obtainAttributes(res, theme, attrs,
                                     AndroidResources.styleable_AnimatedVectorDrawable);
 
                     int drawableRes = a.getResourceId(
diff --git a/graphics/drawable/static/api/current.txt b/graphics/drawable/static/api/current.txt
deleted file mode 100644
index db07bf2..0000000
--- a/graphics/drawable/static/api/current.txt
+++ /dev/null
@@ -1,16 +0,0 @@
-package android.support.graphics.drawable {
-
-   abstract class VectorDrawableCommon extends android.graphics.drawable.Drawable {
-  }
-
-  public class VectorDrawableCompat extends android.support.graphics.drawable.VectorDrawableCommon {
-    method public static android.support.graphics.drawable.VectorDrawableCompat create(android.content.res.Resources, int, android.content.res.Resources.Theme);
-    method public static android.support.graphics.drawable.VectorDrawableCompat createFromXmlInner(android.content.res.Resources, org.xmlpull.v1.XmlPullParser, android.util.AttributeSet, android.content.res.Resources.Theme) throws java.io.IOException, org.xmlpull.v1.XmlPullParserException;
-    method public void draw(android.graphics.Canvas);
-    method public int getOpacity();
-    method public void setAlpha(int);
-    method public void setColorFilter(android.graphics.ColorFilter);
-  }
-
-}
-
diff --git a/graphics/drawable/static/api/removed.txt b/graphics/drawable/static/api/removed.txt
deleted file mode 100644
index e69de29..0000000
--- a/graphics/drawable/static/api/removed.txt
+++ /dev/null
diff --git a/graphics/drawable/static/build.gradle b/graphics/drawable/static/build.gradle
index 2564a27..24d0d50 100644
--- a/graphics/drawable/static/build.gradle
+++ b/graphics/drawable/static/build.gradle
@@ -1,8 +1,8 @@
 apply plugin: 'com.android.library'
-
 archivesBaseName = 'support-vector-drawable'
 
 dependencies {
+    compile project(':support-annotations')
     compile project(':support-compat')
     androidTestCompile ("com.android.support.test:runner:${project.rootProject.ext.testRunnerVersion}") {
         exclude module: 'support-annotations'
@@ -14,11 +14,12 @@
 }
 
 android {
-    compileSdkVersion 23
+    compileSdkVersion project.ext.currentSdk
 
     defaultConfig {
         minSdkVersion 9
         testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
+
         // This disables the builds tools automatic vector -> PNG generation
         generatedDensities = []
     }
diff --git a/graphics/drawable/static/src/android/support/graphics/drawable/VectorDrawableCommon.java b/graphics/drawable/static/src/android/support/graphics/drawable/VectorDrawableCommon.java
index bcabd99..7f91868 100644
--- a/graphics/drawable/static/src/android/support/graphics/drawable/VectorDrawableCommon.java
+++ b/graphics/drawable/static/src/android/support/graphics/drawable/VectorDrawableCommon.java
@@ -35,8 +35,10 @@
     /**
      * Obtains styled attributes from the theme, if available, or unstyled
      * resources if the theme is null.
+     *
+     * @hide
      */
-    static TypedArray obtainAttributes(
+    protected static TypedArray obtainAttributes(
             Resources res, Resources.Theme theme, AttributeSet set, int[] attrs) {
         if (theme == null) {
             return res.obtainAttributes(set, attrs);
diff --git a/media-compat/Android.mk b/media-compat/Android.mk
index d1c2569..da9686c 100644
--- a/media-compat/Android.mk
+++ b/media-compat/Android.mk
@@ -14,109 +14,35 @@
 
 LOCAL_PATH := $(call my-dir)
 
-# -----------------------------------------------------------------------
-
-# A helper sub-library that makes direct use of Ice Cream Sandwich APIs.
-include $(CLEAR_VARS)
-LOCAL_MODULE := android-support-media-compat-ics
-LOCAL_SDK_VERSION := 14
-LOCAL_SRC_FILES := $(call all-java-files-under, ics)
-LOCAL_STATIC_JAVA_LIBRARIES := android-support-annotations android-support-compat
-LOCAL_JAVA_LANGUAGE_VERSION := 1.7
-include $(BUILD_STATIC_JAVA_LIBRARY)
-
-# -----------------------------------------------------------------------
-
-# A helper sub-library that makes direct use of JellyBean MR2 APIs.
-include $(CLEAR_VARS)
-LOCAL_MODULE := android-support-media-compat-jellybean-mr2
-LOCAL_SDK_VERSION := 18
-LOCAL_SRC_FILES := $(call all-java-files-under, jellybean-mr2)
-LOCAL_STATIC_JAVA_LIBRARIES := android-support-media-compat-ics
-LOCAL_JAVA_LANGUAGE_VERSION := 1.7
-include $(BUILD_STATIC_JAVA_LIBRARY)
-
-# -----------------------------------------------------------------------
-
-# A helper sub-library that makes direct use of KitKat APIs.
-include $(CLEAR_VARS)
-LOCAL_MODULE := android-support-media-compat-kitkat
-LOCAL_SDK_VERSION := 19
-LOCAL_SRC_FILES := $(call all-java-files-under, kitkat)
-LOCAL_STATIC_JAVA_LIBRARIES := android-support-media-compat-jellybean-mr2
-LOCAL_JAVA_LANGUAGE_VERSION := 1.7
-include $(BUILD_STATIC_JAVA_LIBRARY)
-
-# -----------------------------------------------------------------------
-
-# A helper sub-library that makes direct use of Lollipop APIs.
-include $(CLEAR_VARS)
-LOCAL_MODULE := android-support-media-compat-api21
-LOCAL_SDK_VERSION := 21
-LOCAL_SRC_FILES := $(call all-java-files-under, api21)
-LOCAL_STATIC_JAVA_LIBRARIES := android-support-media-compat-kitkat
-LOCAL_JAVA_LANGUAGE_VERSION := 1.7
-include $(BUILD_STATIC_JAVA_LIBRARY)
-
-# -----------------------------------------------------------------------
-
-# A helper sub-library that makes direct use of V22 APIs.
-include $(CLEAR_VARS)
-LOCAL_MODULE := android-support-media-compat-api22
-LOCAL_SDK_VERSION := 22
-LOCAL_SRC_FILES := $(call all-java-files-under, api22)
-LOCAL_STATIC_JAVA_LIBRARIES := android-support-media-compat-api21
-LOCAL_JAVA_LANGUAGE_VERSION := 1.7
-include $(BUILD_STATIC_JAVA_LIBRARY)
-
-# -----------------------------------------------------------------------
-
-# A helper sub-library that makes direct use of V23 APIs.
-include $(CLEAR_VARS)
-LOCAL_MODULE := android-support-media-compat-api23
-LOCAL_SDK_VERSION := 23
-LOCAL_SRC_FILES := $(call all-java-files-under, api23)
-LOCAL_STATIC_JAVA_LIBRARIES := android-support-media-compat-api22
-LOCAL_JAVA_LANGUAGE_VERSION := 1.7
-include $(BUILD_STATIC_JAVA_LIBRARY)
-
-# -----------------------------------------------------------------------
-
-# A helper sub-library that makes direct use of V24 APIs.
-include $(CLEAR_VARS)
-LOCAL_MODULE := android-support-media-compat-api24
-LOCAL_SDK_VERSION := 24
-LOCAL_SRC_FILES := $(call all-java-files-under, api24)
-LOCAL_STATIC_JAVA_LIBRARIES := android-support-media-compat-api23
-LOCAL_JAVA_LANGUAGE_VERSION := 1.7
-include $(BUILD_STATIC_JAVA_LIBRARY)
-
-# -----------------------------------------------------------------------
-
-# A helper sub-library that makes direct use of V25 APIs.
-include $(CLEAR_VARS)
-LOCAL_MODULE := android-support-media-compat-api25
-LOCAL_SDK_VERSION := $(SUPPORT_CURRENT_SDK_VERSION)
-LOCAL_SRC_FILES := $(call all-java-files-under, api25)
-LOCAL_STATIC_JAVA_LIBRARIES := android-support-media-compat-api24
-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-media-compat \
+#       android-support-compat \
+#
+# in their makefiles to include the resources and their dependencies in their package.
 include $(CLEAR_VARS)
 LOCAL_USE_AAPT2 := true
 LOCAL_MODULE := android-support-media-compat
-LOCAL_SDK_VERSION := 9
-LOCAL_AIDL_INCLUDES := frameworks/support/media-compat/java
-LOCAL_SRC_FILES := $(call all-java-files-under, java) \
-    $(call all-Iaidl-files-under, java)
+LOCAL_SDK_VERSION := $(SUPPORT_CURRENT_SDK_VERSION)
+LOCAL_AIDL_INCLUDES := $(LOCAL_PATH)/java
+LOCAL_SRC_FILES := \
+    $(call all-java-files-under,ics) \
+    $(call all-java-files-under,jellybean-mr2) \
+    $(call all-java-files-under,kitkat) \
+    $(call all-java-files-under,api21) \
+    $(call all-java-files-under,api22) \
+    $(call all-java-files-under,api23) \
+    $(call all-java-files-under,api24) \
+    $(call all-java-files-under,api25) \
+    $(call all-java-files-under,java) \
+    $(call all-Iaidl-files-under,java)
 LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res
-LOCAL_STATIC_JAVA_LIBRARIES += android-support-media-compat-api25
 LOCAL_SHARED_ANDROID_LIBRARIES := \
     android-support-compat \
     android-support-annotations
 LOCAL_JAR_EXCLUDE_FILES := none
 LOCAL_JAVA_LANGUAGE_VERSION := 1.7
+LOCAL_AAPT_FLAGS := --add-javadoc-annotation doconly
 include $(BUILD_STATIC_JAVA_LIBRARY)
diff --git a/media-compat/build.gradle b/media-compat/build.gradle
index 3e547b3..4b569a4 100644
--- a/media-compat/build.gradle
+++ b/media-compat/build.gradle
@@ -1,9 +1,8 @@
 apply plugin: 'com.android.library'
 archivesBaseName = 'support-media-compat'
 
-
-createApiSourceSets(project, gradle.ext.studioCompat.modules.mediacompat.apiTargets)
 dependencies {
+    compile project(':support-annotations')
     compile project(':support-compat')
     androidTestCompile ("com.android.support.test:runner:${project.rootProject.ext.testRunnerVersion}") {
         exclude module: 'support-annotations'
@@ -18,20 +17,27 @@
 
 sourceCompatibility = JavaVersion.VERSION_1_7
 targetCompatibility = JavaVersion.VERSION_1_7
-setApiModuleDependencies(project, dependencies, gradle.ext.studioCompat.modules.mediacompat.dependencies)
 
 android {
-    compileSdkVersion 9
+    compileSdkVersion project.ext.currentSdk
 
     defaultConfig {
         minSdkVersion 9
-        // TODO: get target from branch
-        //targetSdkVersion 19
     }
 
     sourceSets {
         main.manifest.srcFile 'AndroidManifest.xml'
-        main.java.srcDirs = ['java']
+        main.java.srcDirs = [
+                'ics',
+                'jellybean-mr2',
+                'kitkat',
+                'api21',
+                'api22',
+                'api23',
+                'api24',
+                'api25',
+                'java'
+        ]
         main.aidl.srcDirs = ['java']
     }
 
@@ -77,11 +83,6 @@
         exclude('android/service/media/**')
     }
 
-    project.ext.allSS.each { ss ->
-        javadocTask.source ss.java
-        sourcesJarTask.from ss.java.srcDirs
-    }
-
     artifacts.add('archives', javadocJarTask);
     artifacts.add('archives', sourcesJarTask);
 }
diff --git a/recommendation/Android.mk b/recommendation/Android.mk
index 85b0817..0e0a9d7 100644
--- a/recommendation/Android.mk
+++ b/recommendation/Android.mk
@@ -1,18 +1,37 @@
-LOCAL_PATH:= $(call my-dir)
+# 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 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.
+
+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-recommendation \
+#       android-support-v4
+#
 include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := optional
-LOCAL_SDK_VERSION := 21
-
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-
-
-LOCAL_JAVA_LIBRARIES := \
-    android-support-v4
-
+LOCAL_USE_AAPT2 := true
 LOCAL_MODULE := android-support-recommendation
-
+LOCAL_SDK_VERSION := 21
+LOCAL_SRC_FILES := $(call all-java-files-under, src)
+LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res
+LOCAL_SHARED_ANDROID_LIBRARIES := \
+    android-support-v4 \
+    android-support-annotations
 LOCAL_JAVA_LANGUAGE_VERSION := 1.7
+LOCAL_AAPT_FLAGS := --add-javadoc-annotation doconly
 include $(BUILD_STATIC_JAVA_LIBRARY)
 
 # ===========================================================
@@ -38,7 +57,7 @@
 LOCAL_IS_HOST_MODULE := false
 LOCAL_DROIDDOC_CUSTOM_TEMPLATE_DIR := build/tools/droiddoc/templates-sdk
 
-LOCAL_JAVA_LIBRARIES := $(recommendation.docs.java_libraries)
+LOCAL_SHARED_ANDROID_LIBRARIES := $(recommendation.docs.java_libraries)
 
 LOCAL_DROIDDOC_OPTIONS := \
     -offlinemode \
diff --git a/transition/Android.mk b/transition/Android.mk
index 2de641a..c468ef1 100644
--- a/transition/Android.mk
+++ b/transition/Android.mk
@@ -14,91 +14,30 @@
 
 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_USE_AAPT2 := true
-LOCAL_MODULE := android-support-transition-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)
-
-# A helper sub-library to resolve cyclic dependencies between Transition and platform dependent
-# implementations
-include $(CLEAR_VARS)
-LOCAL_MODULE := android-support-transition-base
-LOCAL_SDK_VERSION := 14
-LOCAL_SRC_FILES := $(call all-java-files-under, base)
-LOCAL_JAVA_LANGUAGE_VERSION := 1.7
-LOCAL_JAVA_LIBRARIES := android-support-transition-res \
-    android-support-compat
-include $(BUILD_STATIC_JAVA_LIBRARY)
-
-# A helper sub-library that makes direct use of Ice Cream Sandwich APIs
-include $(CLEAR_VARS)
-LOCAL_MODULE := android-support-transition-ics
-LOCAL_SDK_VERSION := 14
-LOCAL_SRC_FILES := $(call all-java-files-under, ics)
-LOCAL_JAVA_LANGUAGE_VERSION := 1.7
-LOCAL_STATIC_JAVA_LIBRARIES := android-support-transition-base
-LOCAL_JAVA_LIBRARIES := android-support-transition-res \
-    android-support-compat
-include $(BUILD_STATIC_JAVA_LIBRARY)
-
-# A helper sub-library that makes direct use of KitKat APIs
-include $(CLEAR_VARS)
-LOCAL_MODULE := android-support-transition-kitkat
-LOCAL_SDK_VERSION := 19
-LOCAL_SRC_FILES := $(call all-java-files-under, kitkat)
-LOCAL_JAVA_LANGUAGE_VERSION := 1.7
-LOCAL_STATIC_JAVA_LIBRARIES := android-support-transition-ics
-LOCAL_JAVA_LIBRARIES := android-support-transition-res \
-    android-support-compat
-include $(BUILD_STATIC_JAVA_LIBRARY)
-
-# A helper sub-library that makes direct use of Lollipop APIs
-include $(CLEAR_VARS)
-LOCAL_MODULE := android-support-transition-api21
-LOCAL_SDK_VERSION := 21
-LOCAL_SRC_FILES := $(call all-java-files-under, api21)
-LOCAL_JAVA_LANGUAGE_VERSION := 1.7
-LOCAL_STATIC_JAVA_LIBRARIES := android-support-transition-kitkat
-LOCAL_JAVA_LIBRARIES := android-support-transition-res \
-    android-support-compat
-include $(BUILD_STATIC_JAVA_LIBRARY)
-
-# A helper sub-library that makes direct use of Marshmallow APIs
-include $(CLEAR_VARS)
-LOCAL_MODULE := android-support-transition-api23
-LOCAL_SDK_VERSION := 23
-LOCAL_SRC_FILES := $(call all-java-files-under, api23)
-LOCAL_JAVA_LANGUAGE_VERSION := 1.7
-LOCAL_STATIC_JAVA_LIBRARIES := android-support-transition-api21
-LOCAL_JAVA_LIBRARIES := android-support-transition-res \
-    android-support-compat
-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-transition \
-#       android-support-compat
+#       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-transition
 LOCAL_SDK_VERSION := $(SUPPORT_CURRENT_SDK_VERSION)
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-LOCAL_JAVA_LANGUAGE_VERSION := 1.7
-LOCAL_STATIC_JAVA_LIBRARIES := android-support-transition-api23
-LOCAL_STATIC_ANDROID_LIBRARIES := android-support-transition-res
-LOCAL_SHARED_ANDROID_LIBRARIES := android-support-compat
+LOCAL_SRC_FILES := \
+    $(call all-java-files-under,base) \
+    $(call all-java-files-under,ics) \
+    $(call all-java-files-under,kitkat) \
+    $(call all-java-files-under,api21) \
+    $(call all-java-files-under,api23) \
+    $(call all-java-files-under,src)
+LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res
+LOCAL_SHARED_ANDROID_LIBRARIES := \
+    android-support-annotations \
+    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)
diff --git a/transition/build.gradle b/transition/build.gradle
index f06b0bd..4d4e96f 100644
--- a/transition/build.gradle
+++ b/transition/build.gradle
@@ -3,7 +3,8 @@
 archivesBaseName = 'transition'
 
 dependencies {
-    compile project(':support-compat')
+    compile project(':support-annotations')
+    compile project(':support-v4')
 
     androidTestCompile ("com.android.support.test:runner:${project.rootProject.ext.testRunnerVersion}") {
         exclude module: 'support-annotations'
@@ -27,10 +28,18 @@
 
     sourceSets {
         main.manifest.srcFile 'AndroidManifest.xml'
-        main.java.srcDirs = ['base', 'ics', 'kitkat', 'api21', 'api23', 'src']
-        main.res.srcDirs 'res', 'res-public'
-        main.assets.srcDir 'assets'
-        main.resources.srcDir 'src'
+        main.java.srcDirs = [
+                'base',
+                'ics',
+                'kitkat',
+                'api21',
+                'api23',
+                'src'
+        ]
+        main.res.srcDirs = [
+                'res',
+                'res-public'
+        ]
 
         androidTest.setRoot('tests')
         androidTest.java.srcDir 'tests/src'
diff --git a/v13/Android.mk b/v13/Android.mk
index 00675b7..1b30d99 100644
--- a/v13/Android.mk
+++ b/v13/Android.mk
@@ -14,63 +14,34 @@
 
 LOCAL_PATH := $(call my-dir)
 
-# Note: the source code is in java/, not src/, because this code is also part of
-# the framework library, and build/core/pathmap.mk expects a java/ subdirectory.
-
-# A helper sub-library that makes direct use of Ice Cream Sandwich APIs.
-include $(CLEAR_VARS)
-LOCAL_MODULE := android-support-v13-ics
-LOCAL_SDK_VERSION := 14
-LOCAL_SRC_FILES := $(call all-java-files-under, ics)
-LOCAL_JAVA_LANGUAGE_VERSION := 1.7
-include $(BUILD_STATIC_JAVA_LIBRARY)
-
-# A helper sub-library that makes direct use of Ice Cream Sandwich APIs.
-include $(CLEAR_VARS)
-LOCAL_MODULE := android-support-v13-ics-mr1
-LOCAL_SDK_VERSION := 15
-LOCAL_SRC_FILES := $(call all-java-files-under, ics-mr1)
-LOCAL_STATIC_JAVA_LIBRARIES := android-support-v13-ics
-LOCAL_JAVA_LANGUAGE_VERSION := 1.7
-include $(BUILD_STATIC_JAVA_LIBRARY)
-
-# A helper sub-library that makes direct use of MNC APIs.
-include $(CLEAR_VARS)
-LOCAL_MODULE := android-support-v13-mnc
-LOCAL_SDK_VERSION := 23
-LOCAL_SRC_FILES := $(call all-java-files-under, api23)
-LOCAL_STATIC_JAVA_LIBRARIES := android-support-v13-ics-mr1
-LOCAL_JAVA_LANGUAGE_VERSION := 1.7
-include $(BUILD_STATIC_JAVA_LIBRARY)
-
-# A helper sub-library that makes direct use of NYC APIs.
-include $(CLEAR_VARS)
-LOCAL_MODULE := android-support-v13-nyc
-LOCAL_SDK_VERSION := 24
-LOCAL_SRC_FILES := $(call all-java-files-under, api24)
-LOCAL_STATIC_JAVA_LIBRARIES := android-support-v13-mnc
-LOCAL_JAVA_LANGUAGE_VERSION := 1.7
-include $(BUILD_STATIC_JAVA_LIBRARY)
-
-# A helper sub-library that makes direct use of NYC MR-1 APIs.
-include $(CLEAR_VARS)
-LOCAL_MODULE := android-support-v13-nyc-mr1
-LOCAL_SDK_VERSION := current
-LOCAL_SRC_FILES := $(call all-java-files-under, api25)
-LOCAL_STATIC_JAVA_LIBRARIES := android-support-v13-nyc
-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-v13 \
+#       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-v13
-LOCAL_SDK_VERSION := 13
-LOCAL_SRC_FILES := $(call all-java-files-under, java)
+LOCAL_SDK_VERSION := $(SUPPORT_CURRENT_SDK_VERSION)
+LOCAL_SRC_FILES := \
+        $(call all-java-files-under, ics) \
+        $(call all-java-files-under, ics-mr1) \
+        $(call all-java-files-under, api23) \
+        $(call all-java-files-under, api24) \
+        $(call all-java-files-under, api25) \
+        $(call all-java-files-under, java)
 LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res
-LOCAL_STATIC_JAVA_LIBRARIES += android-support-v4 \
-        android-support-v13-nyc-mr1
+# Some projects expect to inherit android-support-v4 from
+# android-support-v13, so we need to keep it static until they can be fixed.
+LOCAL_STATIC_ANDROID_LIBRARIES := \
+        android-support-v4
+LOCAL_SHARED_ANDROID_LIBRARIES := \
+        android-support-v4 \
+        android-support-annotations
 LOCAL_JAVA_LANGUAGE_VERSION := 1.7
+LOCAL_AAPT_FLAGS := --add-javadoc-annotation doconly
 include $(BUILD_STATIC_JAVA_LIBRARY)
 
diff --git a/v13/build.gradle b/v13/build.gradle
index 4baaa27..5e1a026 100644
--- a/v13/build.gradle
+++ b/v13/build.gradle
@@ -1,33 +1,28 @@
 apply plugin: 'com.android.library'
-
 archivesBaseName = 'support-v13'
 
-sourceCompatibility = JavaVersion.VERSION_1_7
-targetCompatibility = JavaVersion.VERSION_1_7
+dependencies {
+    compile project(':support-annotations')
+    compile project(':support-v4')
+}
 
-createApiSourceSets(project, gradle.ext.studioCompat.modules.v13.apiTargets)
-setApiModuleDependencies(project, dependencies, gradle.ext.studioCompat.modules.v13.dependencies)
 android {
-    compileSdkVersion 13
+    compileSdkVersion project.ext.currentSdk
 
     defaultConfig {
         minSdkVersion 13
-        // TODO: get target from branch
-        //targetSdkVersion 19
     }
 
     sourceSets {
         main.manifest.srcFile 'AndroidManifest.xml'
-        main.java.srcDirs = ['java']
-        main.aidl.srcDirs = ['java']
-
-        androidTest.setRoot('tests')
-        androidTest.java.srcDir 'tests/java'
-    }
-
-    compileOptions {
-        sourceCompatibility JavaVersion.VERSION_1_7
-        targetCompatibility JavaVersion.VERSION_1_7
+        main.java.srcDirs = [
+                'ics',
+                'ics-mr1',
+                'api23',
+                'api24',
+                'api25',
+                'java'
+        ]
     }
 
     lintOptions {
@@ -70,11 +65,6 @@
         from android.sourceSets.main.java.srcDirs
     }
 
-    project.ext.allSS.each { ss ->
-        javadocTask.source ss.java
-        sourcesJarTask.from ss.java.srcDirs
-    }
-
     artifacts.add('archives', javadocJarTask);
     artifacts.add('archives', sourcesJarTask);
 }
diff --git a/v14/preference/Android.mk b/v14/preference/Android.mk
index f359486..7a0b846 100644
--- a/v14/preference/Android.mk
+++ b/v14/preference/Android.mk
@@ -22,15 +22,13 @@
 #       android-support-v7-preference \
 #       android-support-v7-appcompat \
 #       android-support-v7-recyclerview \
-#       android-support-v4 \
-#       android-support-annotations
+#       android-support-v4
 #
 # 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_SDK_VERSION := $(SUPPORT_CURRENT_SDK_VERSION)
 LOCAL_SRC_FILES := $(call all-java-files-under,src)
 LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res
 LOCAL_SHARED_ANDROID_LIBRARIES := \
diff --git a/v14/preference/build.gradle b/v14/preference/build.gradle
index b834dd5..33d616e 100644
--- a/v14/preference/build.gradle
+++ b/v14/preference/build.gradle
@@ -30,6 +30,10 @@
 android {
     compileSdkVersion project.ext.currentSdk
 
+    defaultConfig {
+        minSdkVersion 14
+    }
+
     sourceSets {
         main.manifest.srcFile 'AndroidManifest.xml'
         main.java.srcDir 'src'
diff --git a/v17/leanback/Android.mk b/v17/leanback/Android.mk
index b550fe0..271cab1 100644
--- a/v17/leanback/Android.mk
+++ b/v17/leanback/Android.mk
@@ -14,111 +14,27 @@
 
 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_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_JAR_EXCLUDE_FILES := none
-LOCAL_JAVA_LANGUAGE_VERSION := 1.7
-include $(BUILD_STATIC_JAVA_LIBRARY)
-
-# -----------------------------------------------------------------------
-
-#  Base sub-library contains classes both needed by api-level specific libraries
-#  (e.g. KitKat) and final static library.
-include $(CLEAR_VARS)
-LOCAL_MODULE := android-support-v17-leanback-common
-LOCAL_SDK_VERSION := 17
-LOCAL_SRC_FILES := $(call all-java-files-under, common)
-LOCAL_JAVA_LANGUAGE_VERSION := 1.7
-LOCAL_SHARED_ANDROID_LIBRARIES := \
-    android-support-annotations
-include $(BUILD_STATIC_JAVA_LIBRARY)
-
-# -----------------------------------------------------------------------
-
-#  A helper sub-library that makes direct use of API 23.
-include $(CLEAR_VARS)
-LOCAL_MODULE := android-support-v17-leanback-api23
-LOCAL_SDK_VERSION := 23
-LOCAL_SRC_FILES := $(call all-java-files-under, api23)
-LOCAL_JAVA_LIBRARIES := android-support-v17-leanback-res android-support-v17-leanback-common
-LOCAL_JAVA_LANGUAGE_VERSION := 1.7
-LOCAL_SHARED_ANDROID_LIBRARIES := \
-    android-support-annotations
-include $(BUILD_STATIC_JAVA_LIBRARY)
-
-# -----------------------------------------------------------------------
-
-#  A helper sub-library that makes direct use of API 21.
-include $(CLEAR_VARS)
-LOCAL_MODULE := android-support-v17-leanback-api21
-LOCAL_SDK_VERSION := 21
-LOCAL_SRC_FILES := $(call all-java-files-under, api21)
-LOCAL_JAVA_LIBRARIES := android-support-v17-leanback-res android-support-v17-leanback-common
-LOCAL_JAVA_LANGUAGE_VERSION := 1.7
-LOCAL_SHARED_ANDROID_LIBRARIES := \
-    android-support-annotations
-include $(BUILD_STATIC_JAVA_LIBRARY)
-
-# -----------------------------------------------------------------------
-
-#  A helper sub-library that makes direct use of KitKat APIs.
-include $(CLEAR_VARS)
-LOCAL_MODULE := android-support-v17-leanback-kitkat
-LOCAL_SDK_VERSION := 19
-LOCAL_SRC_FILES := $(call all-java-files-under, kitkat)
-LOCAL_JAVA_LIBRARIES := android-support-v17-leanback-res android-support-v17-leanback-common
-LOCAL_JAVA_LANGUAGE_VERSION := 1.7
-LOCAL_SHARED_ANDROID_LIBRARIES := \
-    android-support-annotations
-include $(BUILD_STATIC_JAVA_LIBRARY)
-
-# -----------------------------------------------------------------------
-
-#  A helper sub-library that makes direct use of JBMR2 APIs.
-include $(CLEAR_VARS)
-LOCAL_MODULE := android-support-v17-leanback-jbmr2
-LOCAL_SDK_VERSION := 18
-LOCAL_SRC_FILES := $(call all-java-files-under, jbmr2)
-LOCAL_JAVA_LIBRARIES := android-support-v17-leanback-res android-support-v17-leanback-common
-LOCAL_JAVA_LANGUAGE_VERSION := 1.7
-LOCAL_SHARED_ANDROID_LIBRARIES := \
-    android-support-annotations
-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-v17-leanback \
 #       android-support-v7-recyclerview \
-#       android-support-v4 \
-#       android-support-annotations
+#       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-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_SDK_VERSION := $(SUPPORT_CURRENT_SDK_VERSION)
+LOCAL_SRC_FILES := \
+    $(call all-java-files-under, common) \
+    $(call all-java-files-under, jbmr2) \
+    $(call all-java-files-under, kitkat) \
+    $(call all-java-files-under, api21) \
+    $(call all-java-files-under, api23) \
+    $(call all-java-files-under, src)
+LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res
 LOCAL_SHARED_ANDROID_LIBRARIES := \
     android-support-v7-recyclerview \
     android-support-compat \
diff --git a/v17/leanback/build.gradle b/v17/leanback/build.gradle
index d7eea85..270f552 100644
--- a/v17/leanback/build.gradle
+++ b/v17/leanback/build.gradle
@@ -1,5 +1,4 @@
 apply plugin: 'com.android.library'
-
 archivesBaseName = 'leanback-v17'
 
 dependencies {
@@ -21,22 +20,24 @@
 }
 
 android {
-    // WARNING: should be 17
     compileSdkVersion project.ext.currentSdk
 
     defaultConfig {
         minSdkVersion 17
-        // TODO: get target from branch
-        //targetSdkVersion 19
-
         testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
     }
 
     sourceSets {
         main.manifest.srcFile 'AndroidManifest.xml'
-        main.java.srcDirs = ['common', 'jbmr2', 'kitkat', 'api21', 'api23', 'src']
-        main.aidl.srcDirs = ['common', 'jbmr2', 'kitkat', 'api21', 'api23', 'src']
-        main.res.srcDirs = ['res']
+        main.java.srcDirs = [
+                'common',
+                'jbmr2',
+                'kitkat',
+                'api21',
+                'api23',
+                'src'
+        ]
+        main.res.srcDir 'res'
 
         androidTest.setRoot('tests')
         androidTest.java.srcDir 'tests/java'
diff --git a/v17/preference-leanback/Android.mk b/v17/preference-leanback/Android.mk
index 2058002..263d334 100644
--- a/v17/preference-leanback/Android.mk
+++ b/v17/preference-leanback/Android.mk
@@ -14,45 +14,6 @@
 
 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 \
-    android-support-annotations
-
-# 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_JAR_EXCLUDE_FILES := none
-include $(BUILD_STATIC_JAVA_LIBRARY)
-
-# -----------------------------------------------------------------------
-
-#  A helper sub-library that makes direct use of API 21.
-include $(CLEAR_VARS)
-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_SHARED_ANDROID_LIBRARIES := \
-    android-support-annotations
-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
 #
@@ -63,23 +24,25 @@
 #       android-support-v7-preference \
 #       android-support-v7-appcompat \
 #       android-support-v7-recyclerview \
-#       android-support-v4 \
-#       android-support-annotations
+#       android-support-v4
 #
 # 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_SDK_VERSION := $(SUPPORT_CURRENT_SDK_VERSION)
+LOCAL_SRC_FILES := \
+    $(call all-java-files-under,api21) \
+    $(call all-java-files-under,src)
+LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res
 LOCAL_SHARED_ANDROID_LIBRARIES := \
-    $(resource_libs) \
-    android-support-v4
+    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-annotations
 LOCAL_JAR_EXCLUDE_FILES := none
 LOCAL_JAVA_LANGUAGE_VERSION := 1.7
 LOCAL_AAPT_FLAGS := --add-javadoc-annotation doconly
diff --git a/v17/preference-leanback/build.gradle b/v17/preference-leanback/build.gradle
index dbdce7e..2f4ec5b 100644
--- a/v17/preference-leanback/build.gradle
+++ b/v17/preference-leanback/build.gradle
@@ -1,23 +1,4 @@
-/*
- * 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 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
- */
-
-
-
 apply plugin: 'com.android.library'
-
 archivesBaseName = 'preference-leanback-v17'
 
 dependencies {
@@ -34,16 +15,14 @@
 
     sourceSets {
         main.manifest.srcFile 'AndroidManifest.xml'
-        main.java.srcDirs = ['src', 'api21']
+        main.java.srcDirs = [
+                'api21',
+                'src'
+        ]
         main.res.srcDir 'res'
-        main.assets.srcDir 'assets'
-        main.resources.srcDir 'src'
+    }
 
-        // this moves src/instrumentTest to tests so all folders follow:
-        // tests/java, tests/res, tests/assets, ...
-        // This is a *reset* so it replaces the default paths
-        androidTest.setRoot('tests')
-        androidTest.java.srcDir 'tests/src'
+    lintOptions {
     }
 
     compileOptions {
diff --git a/v4/Android.mk b/v4/Android.mk
index d183f4d..a9c9145 100644
--- a/v4/Android.mk
+++ b/v4/Android.mk
@@ -24,14 +24,18 @@
 include $(CLEAR_VARS)
 LOCAL_USE_AAPT2 := true
 LOCAL_MODULE := android-support-v4
-LOCAL_SDK_VERSION := 9
+LOCAL_SDK_VERSION := $(SUPPORT_CURRENT_SDK_VERSION)
+# Some projects expect to inherit android-support-annotations from
+# android-support-v4, so we need to keep it static until they can be fixed.
 LOCAL_STATIC_JAVA_LIBRARIES := \
     android-support-compat \
     android-support-media-compat \
     android-support-core-utils \
     android-support-core-ui \
-    android-support-fragment
+    android-support-fragment \
+    android-support-annotations
 LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res
 LOCAL_JAR_EXCLUDE_FILES := none
 LOCAL_JAVA_LANGUAGE_VERSION := 1.7
+LOCAL_AAPT_FLAGS := --add-javadoc-annotation doconly
 include $(BUILD_STATIC_JAVA_LIBRARY)
diff --git a/v7/appcompat/Android.mk b/v7/appcompat/Android.mk
index 21e9e8b..93baa95 100644
--- a/v7/appcompat/Android.mk
+++ b/v7/appcompat/Android.mk
@@ -31,7 +31,8 @@
 LOCAL_STATIC_JAVA_LIBRARIES := \
     android-support-vectordrawable \
     android-support-animatedvectordrawable
-LOCAL_JAVA_LIBRARIES := android-support-v4
+LOCAL_SHARED_ANDROID_LIBRARIES := \
+    android-support-v4
 LOCAL_AAPT_FLAGS := --no-version-vectors
 LOCAL_JAR_EXCLUDE_FILES := none
 LOCAL_JAVA_LANGUAGE_VERSION := 1.7
diff --git a/v7/appcompat/build.gradle b/v7/appcompat/build.gradle
index 45ec21f..e6bb42b 100644
--- a/v7/appcompat/build.gradle
+++ b/v7/appcompat/build.gradle
@@ -3,6 +3,7 @@
 archivesBaseName = 'appcompat-v7'
 
 dependencies {
+    compile project(':support-annotations')
     compile project(':support-v4')
     compile project(':support-vector-drawable')
     compile project(':support-animated-vector-drawable')
diff --git a/v7/cardview/Android.mk b/v7/cardview/Android.mk
index 7861dc1..cd3b407 100644
--- a/v7/cardview/Android.mk
+++ b/v7/cardview/Android.mk
@@ -14,63 +14,6 @@
 
 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_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)
-LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res
-LOCAL_JAR_EXCLUDE_FILES := none
-LOCAL_JAVA_LANGUAGE_VERSION := 1.7
-include $(BUILD_STATIC_JAVA_LIBRARY)
-
-# A helper sub-library to resolve cyclic dependencies between CardView and platform dependent
-# implementations
-include $(CLEAR_VARS)
-LOCAL_MODULE := android-support-v7-cardview-base
-LOCAL_SDK_VERSION := 9
-LOCAL_SRC_FILES := $(call all-java-files-under, base)
-LOCAL_JAVA_LIBRARIES := android-support-annotations
-LOCAL_JAVA_LANGUAGE_VERSION := 1.7
-include $(BUILD_STATIC_JAVA_LIBRARY)
-
-# A helper sub-library that makes direct use of Gingerbread APIs
-include $(CLEAR_VARS)
-LOCAL_MODULE := android-support-v7-cardview-gingerbread
-LOCAL_SDK_VERSION := 9
-LOCAL_SRC_FILES := $(call all-java-files-under, gingerbread)
-LOCAL_STATIC_JAVA_LIBRARIES := android-support-v7-cardview-base
-LOCAL_JAVA_LIBRARIES := android-support-v7-cardview-res \
-    android-support-annotations
-LOCAL_JAVA_LANGUAGE_VERSION := 1.7
-include $(BUILD_STATIC_JAVA_LIBRARY)
-
-# A helper sub-library that makes direct use of JB MR1 APIs
-include $(CLEAR_VARS)
-LOCAL_MODULE := android-support-v7-cardview-jellybean-mr1
-LOCAL_SDK_VERSION := 17
-LOCAL_SRC_FILES := $(call all-java-files-under, jellybean-mr1)
-LOCAL_STATIC_JAVA_LIBRARIES := android-support-v7-cardview-gingerbread
-LOCAL_JAVA_LIBRARIES := android-support-v7-cardview-res \
-    android-support-annotations
-LOCAL_JAVA_LANGUAGE_VERSION := 1.7
-include $(BUILD_STATIC_JAVA_LIBRARY)
-
-# A helper sub-library that makes direct use of L APIs
-include $(CLEAR_VARS)
-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 \
-    android-support-annotations
-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
 #
@@ -80,12 +23,16 @@
 include $(CLEAR_VARS)
 LOCAL_USE_AAPT2 := true
 LOCAL_MODULE := android-support-v7-cardview
-LOCAL_SDK_VERSION := 9
-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_SDK_VERSION := $(SUPPORT_CURRENT_SDK_VERSION)
+LOCAL_SRC_FILES := \
+    $(call all-java-files-under,base) \
+    $(call all-java-files-under,gingerbread) \
+    $(call all-java-files-under,jellybean-mr1) \
+    $(call all-java-files-under,api21) \
+    $(call all-java-files-under,src)
+LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res
+LOCAL_SHARED_ANDROID_LIBRARIES := \
+    android-support-annotations
 LOCAL_JAR_EXCLUDE_FILES := none
 LOCAL_JAVA_LANGUAGE_VERSION := 1.7
 LOCAL_AAPT_FLAGS := --add-javadoc-annotation doconly
diff --git a/v7/cardview/build.gradle b/v7/cardview/build.gradle
index e9e0ab5..12f9e39 100644
--- a/v7/cardview/build.gradle
+++ b/v7/cardview/build.gradle
@@ -1,5 +1,4 @@
 apply plugin: 'com.android.library'
-
 archivesBaseName = 'cardview-v7'
 
 dependencies {
@@ -7,25 +6,22 @@
 }
 
 android {
-    // WARNING: should be 7
     compileSdkVersion project.ext.currentSdk
 
     defaultConfig {
         minSdkVersion 9
-        // TODO: get target from branch
-        //targetSdkVersion 19
-    }
-
-    compileOptions {
-        sourceCompatibility JavaVersion.VERSION_1_7
-        targetCompatibility JavaVersion.VERSION_1_7
     }
 
     sourceSets {
         main.manifest.srcFile 'AndroidManifest.xml'
-        main.java.srcDirs = ['base', 'gingerbread', 'jellybean-mr1', 'api21', 'src']
-        main.aidl.srcDirs = ['base', 'gingerbread', 'jellybean-mr1', 'api21', 'src']
-        main.res.srcDirs = ['res']
+        main.java.srcDirs = [
+                'base',
+                'gingerbread',
+                'jellybean-mr1',
+                'api21',
+                'src'
+        ]
+        main.res.srcDir 'res'
 
         androidTest.setRoot('tests')
         androidTest.java.srcDir 'tests/java'
diff --git a/v7/cardview/dummy/Dummy.java b/v7/cardview/dummy/Dummy.java
deleted file mode 100644
index be16dc7..0000000
--- a/v7/cardview/dummy/Dummy.java
+++ /dev/null
@@ -1 +0,0 @@
-// Dummy java file used to build the resource library.
diff --git a/v7/gridlayout/Android.mk b/v7/gridlayout/Android.mk
index 7938918..6eac23b4 100644
--- a/v7/gridlayout/Android.mk
+++ b/v7/gridlayout/Android.mk
@@ -26,10 +26,13 @@
 include $(CLEAR_VARS)
 LOCAL_USE_AAPT2 := true
 LOCAL_MODULE := android-support-v7-gridlayout
+LOCAL_SDK_VERSION := $(SUPPORT_CURRENT_SDK_VERSION)
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
 LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res
-LOCAL_SDK_VERSION := 9
-LOCAL_SHARED_ANDROID_LIBRARIES += android-support-compat android-support-core-ui
+LOCAL_SHARED_ANDROID_LIBRARIES := \
+    android-support-compat \
+    android-support-core-ui \
+    android-support-annotations
 LOCAL_JAR_EXCLUDE_FILES := none
 LOCAL_JAVA_LANGUAGE_VERSION := 1.7
 LOCAL_AAPT_FLAGS := --add-javadoc-annotation doconly
diff --git a/v7/mediarouter/Android.mk b/v7/mediarouter/Android.mk
index 83dedec..21b4a62 100644
--- a/v7/mediarouter/Android.mk
+++ b/v7/mediarouter/Android.mk
@@ -14,55 +14,6 @@
 
 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.
-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_JAR_EXCLUDE_FILES := none
-LOCAL_JAVA_LANGUAGE_VERSION := 1.7
-include $(BUILD_STATIC_JAVA_LIBRARY)
-
-# A helper sub-library that makes direct use of JellyBean APIs.
-include $(CLEAR_VARS)
-LOCAL_MODULE := android-support-v7-mediarouter-jellybean
-LOCAL_SDK_VERSION := 16
-LOCAL_SRC_FILES := $(call all-java-files-under, jellybean)
-LOCAL_JAVA_LANGUAGE_VERSION := 1.7
-include $(BUILD_STATIC_JAVA_LIBRARY)
-
-# A helper sub-library that makes direct use of JellyBean MR1 APIs.
-include $(CLEAR_VARS)
-LOCAL_MODULE := android-support-v7-mediarouter-jellybean-mr1
-LOCAL_SDK_VERSION := 17
-LOCAL_SRC_FILES := $(call all-java-files-under, jellybean-mr1)
-LOCAL_STATIC_JAVA_LIBRARIES := android-support-v7-mediarouter-jellybean
-LOCAL_JAVA_LANGUAGE_VERSION := 1.7
-include $(BUILD_STATIC_JAVA_LIBRARY)
-
-# A helper sub-library that makes direct use of JellyBean MR2 APIs.
-include $(CLEAR_VARS)
-LOCAL_MODULE := android-support-v7-mediarouter-jellybean-mr2
-LOCAL_SDK_VERSION := 18
-LOCAL_SRC_FILES := $(call all-java-files-under, jellybean-mr2)
-LOCAL_STATIC_JAVA_LIBRARIES := android-support-v7-mediarouter-jellybean-mr1
-LOCAL_JAVA_LANGUAGE_VERSION := 1.7
-include $(BUILD_STATIC_JAVA_LIBRARY)
-
-# A helper sub-library that makes direct use of V24 APIs.
-include $(CLEAR_VARS)
-LOCAL_MODULE := android-support-v7-mediarouter-api24
-LOCAL_SDK_VERSION := 24
-LOCAL_SRC_FILES := $(call all-java-files-under, api24)
-LOCAL_STATIC_JAVA_LIBRARIES := android-support-v7-mediarouter-jellybean-mr2
-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
 #
@@ -76,11 +27,14 @@
 include $(CLEAR_VARS)
 LOCAL_USE_AAPT2 := true
 LOCAL_MODULE := android-support-v7-mediarouter
-LOCAL_SDK_VERSION := current
-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_SDK_VERSION := $(SUPPORT_CURRENT_SDK_VERSION)
+LOCAL_SRC_FILES := \
+    $(call all-java-files-under,jellybean) \
+    $(call all-java-files-under,jellybean-mr1) \
+    $(call all-java-files-under,jellybean-mr2) \
+    $(call all-java-files-under,api24) \
+    $(call all-java-files-under,src)
+LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res
 LOCAL_SHARED_ANDROID_LIBRARIES := \
     android-support-v7-appcompat \
     android-support-v7-palette \
diff --git a/v7/mediarouter/build.gradle b/v7/mediarouter/build.gradle
index 16761c2..61a5985 100644
--- a/v7/mediarouter/build.gradle
+++ b/v7/mediarouter/build.gradle
@@ -1,36 +1,28 @@
 apply plugin: 'com.android.library'
-
 archivesBaseName = 'mediarouter-v7'
 
-
-// some of the source requires compiling against a newer API.
-// Right now, use normal Java source sets to compile those into a jar and 
-// package it as a local dependencies inside the library aar.
-
-createApiSourceSets(project, gradle.ext.studioCompat.modules.mediaRouter.apiTargets)
-sourceCompatibility = JavaVersion.VERSION_1_7
-targetCompatibility = JavaVersion.VERSION_1_7
-setApiModuleDependencies(project, dependencies, gradle.ext.studioCompat.modules.mediaRouter.dependencies)
-// keep these dependencies here since API specific implementations don't need to access them.
 dependencies {
     compile project(":support-appcompat-v7")
     compile project(":support-palette-v7")
 }
+
 android {
     compileSdkVersion project.ext.currentSdk
 
+    defaultConfig {
+        minSdkVersion 9
+    }
+
     sourceSets {
         main.manifest.srcFile 'AndroidManifest.xml'
-        main.java.srcDir 'src'
+        main.java.srcDirs = [
+                'jellybean',
+                'jellybean-mr1',
+                'jellybean-mr2',
+                'api24',
+                'src'
+        ]
         main.res.srcDir 'res'
-        main.assets.srcDir 'assets'
-        main.resources.srcDir 'src'
-
-        // this moves src/instrumentTest to tests so all folders follow:
-        // tests/java, tests/res, tests/assets, ...
-        // This is a *reset* so it replaces the default paths
-        androidTest.setRoot('tests')
-        androidTest.java.srcDir 'tests/src'
     }
 
     compileOptions {
@@ -73,11 +65,6 @@
         from android.sourceSets.main.java.srcDirs
     }
 
-    project.ext.allSS.each { ss ->
-        javadocTask.source ss.java
-        sourcesJarTask.from ss.java.srcDirs
-    }
-
     artifacts.add('archives', javadocJarTask);
     artifacts.add('archives', sourcesJarTask);
 }
diff --git a/v7/mediarouter/dummy/Dummy.java b/v7/mediarouter/dummy/Dummy.java
deleted file mode 100644
index be16dc7..0000000
--- a/v7/mediarouter/dummy/Dummy.java
+++ /dev/null
@@ -1 +0,0 @@
-// Dummy java file used to build the resource library.
diff --git a/v7/palette/Android.mk b/v7/palette/Android.mk
index c689297..c21dad3 100644
--- a/v7/palette/Android.mk
+++ b/v7/palette/Android.mk
@@ -26,11 +26,14 @@
 include $(CLEAR_VARS)
 LOCAL_USE_AAPT2 := true
 LOCAL_MODULE := android-support-v7-palette
-LOCAL_SDK_VERSION := 9
+LOCAL_SDK_VERSION := $(SUPPORT_CURRENT_SDK_VERSION)
 LOCAL_SRC_FILES := $(call all-java-files-under, src/main)
-LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res
+LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/src/main/res
 LOCAL_MANIFEST_FILE := src/main/AndroidManifest.xml
-LOCAL_SHARED_ANDROID_LIBRARIES += android-support-compat android-support-core-utils
+LOCAL_SHARED_ANDROID_LIBRARIES := \
+    android-support-compat \
+    android-support-core-utils \
+    android-support-annotations
 LOCAL_JAR_EXCLUDE_FILES := none
 LOCAL_JAVA_LANGUAGE_VERSION := 1.7
 LOCAL_AAPT_FLAGS := --add-javadoc-annotation doconly
diff --git a/v7/preference/Android.mk b/v7/preference/Android.mk
index ca4fe02..e751e1c 100644
--- a/v7/preference/Android.mk
+++ b/v7/preference/Android.mk
@@ -14,23 +14,6 @@
 
 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.
-include $(CLEAR_VARS)
-LOCAL_USE_AAPT2 := true
-LOCAL_MODULE := android-support-v7-preference-res
-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 \
-    android-support-v4 \
-    android-support-annotations
-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
 #
@@ -38,18 +21,17 @@
 #       android-support-v7-preference \
 #       android-support-v7-appcompat \
 #       android-support-v7-recyclerview \
-#       android-support-v4 \
-#       android-support-annotations
+#       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-preference
-LOCAL_SDK_VERSION := 9
-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_SDK_VERSION := $(SUPPORT_CURRENT_SDK_VERSION)
+LOCAL_SRC_FILES := \
+    $(call all-java-files-under,constants) \
+    $(call all-java-files-under,src)
+LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res
 LOCAL_SHARED_ANDROID_LIBRARIES := \
     android-support-v7-appcompat \
     android-support-v7-recyclerview \
diff --git a/v7/preference/build.gradle b/v7/preference/build.gradle
index 61334f9..55fe020 100644
--- a/v7/preference/build.gradle
+++ b/v7/preference/build.gradle
@@ -37,6 +37,7 @@
 
     defaultConfig {
         testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
+        minSdkVersion 9
     }
 
     sourceSets {
diff --git a/v7/recyclerview/Android.mk b/v7/recyclerview/Android.mk
index 52572fe..e434ab2 100644
--- a/v7/recyclerview/Android.mk
+++ b/v7/recyclerview/Android.mk
@@ -18,17 +18,15 @@
 # Applications that use this library must specify
 #
 #   LOCAL_STATIC_ANDROID_LIBRARIES := \
-#       android-support-v7-recycler-view \
+#       android-support-v7-recyclerview \
 #       android-support-compat \
-#       android-support-core-ui \
-#       android-support-annotations
+#       android-support-core-ui
 #
 # 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-recyclerview
-LOCAL_SDK_VERSION := 9
-LOCAL_SDK_RES_VERSION := $(SUPPORT_CURRENT_SDK_VERSION)
+LOCAL_SDK_VERSION := $(SUPPORT_CURRENT_SDK_VERSION)
 LOCAL_SRC_FILES := $(call all-java-files-under,src)
 LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res
 LOCAL_SHARED_ANDROID_LIBRARIES := \
@@ -37,5 +35,5 @@
     android-support-annotations
 LOCAL_JAR_EXCLUDE_FILES := none
 LOCAL_JAVA_LANGUAGE_VERSION := 1.7
+LOCAL_AAPT_FLAGS := --add-javadoc-annotation doconly
 include $(BUILD_STATIC_JAVA_LIBRARY)
-