Allow editing of samples in Android Studio

Running the samples from AS does not work currently
since AS doesn't know how to use the current SDK.

Change-Id: I6c88a76ef9c6948d4595af00be9d7fe60d5faa5d
diff --git a/build.gradle b/build.gradle
index 8d5f9b4..6f499ea 100644
--- a/build.gradle
+++ b/build.gradle
@@ -278,7 +278,8 @@
     mainUpload.dependsOn release
 
     project.plugins.whenPluginAdded { plugin ->
-        if ("com.android.build.gradle.LibraryPlugin".equals(plugin.class.name)) {
+        if ("com.android.build.gradle.LibraryPlugin".equals(plugin.class.name)
+                || "com.android.build.gradle.AppPlugin".equals(plugin.class.name)) {
             project.android.buildToolsVersion = rootProject.buildToolsVersion
             // enable code coverage for debug builds only if we are not running inside the IDE
             // enabling coverage reports breaks the method parameter resolution in the IDE debugger
diff --git a/samples/Support13Demos/build.gradle b/samples/Support13Demos/build.gradle
new file mode 100644
index 0000000..3f78d64
--- /dev/null
+++ b/samples/Support13Demos/build.gradle
@@ -0,0 +1,31 @@
+apply plugin: 'com.android.application'
+
+dependencies {
+    compile project(':support-v13')
+}
+
+android {
+    compileSdkVersion project.ext.currentSdk
+
+    defaultConfig {
+        minSdkVersion 13
+    }
+
+    sourceSets {
+        main.manifest.srcFile 'AndroidManifest.xml'
+        main.java.srcDirs = ['src']
+        main.aidl.srcDirs = ['src']
+        main.res.srcDirs = ['res']
+    }
+
+    lintOptions {
+        // TODO: fix errors and reenable.
+        abortOnError false
+    }
+
+    compileOptions {
+        sourceCompatibility JavaVersion.VERSION_1_7
+        targetCompatibility JavaVersion.VERSION_1_7
+    }
+}
+
diff --git a/samples/Support4Demos/build.gradle b/samples/Support4Demos/build.gradle
new file mode 100644
index 0000000..26d8113
--- /dev/null
+++ b/samples/Support4Demos/build.gradle
@@ -0,0 +1,31 @@
+apply plugin: 'com.android.application'
+
+dependencies {
+    compile project(':support-v4')
+}
+
+android {
+    compileSdkVersion project.ext.currentSdk
+
+    defaultConfig {
+        minSdkVersion 9
+    }
+
+    sourceSets {
+        main.manifest.srcFile 'AndroidManifest.xml'
+        main.java.srcDirs = ['src']
+        main.aidl.srcDirs = ['src']
+        main.res.srcDirs = ['res']
+    }
+
+    lintOptions {
+        // TODO: fix errors and reenable.
+        abortOnError false
+    }
+
+    compileOptions {
+        sourceCompatibility JavaVersion.VERSION_1_7
+        targetCompatibility JavaVersion.VERSION_1_7
+    }
+}
+
diff --git a/samples/Support7Demos/build.gradle b/samples/Support7Demos/build.gradle
new file mode 100644
index 0000000..ac8dc3c
--- /dev/null
+++ b/samples/Support7Demos/build.gradle
@@ -0,0 +1,36 @@
+apply plugin: 'com.android.application'
+
+dependencies {
+    compile project(':support-appcompat-v7')
+    compile project(':support-cardview-v7')
+    compile project(':support-gridlayout-v7')
+    compile project(':support-mediarouter-v7')
+    compile project(':support-palette-v7')
+    compile project(':support-recyclerview-v7')
+}
+
+android {
+    compileSdkVersion project.ext.currentSdk
+
+    defaultConfig {
+        minSdkVersion 9
+    }
+
+    sourceSets {
+        main.manifest.srcFile 'AndroidManifest.xml'
+        main.java.srcDirs = ['src']
+        main.aidl.srcDirs = ['src']
+        main.res.srcDirs = ['res']
+    }
+
+    lintOptions {
+        // TODO: fix errors and reenable.
+        abortOnError false
+    }
+
+    compileOptions {
+        sourceCompatibility JavaVersion.VERSION_1_7
+        targetCompatibility JavaVersion.VERSION_1_7
+    }
+}
+
diff --git a/samples/SupportDesignDemos/build.gradle b/samples/SupportDesignDemos/build.gradle
new file mode 100644
index 0000000..163bb61
--- /dev/null
+++ b/samples/SupportDesignDemos/build.gradle
@@ -0,0 +1,31 @@
+apply plugin: 'com.android.application'
+
+dependencies {
+    compile project(':support-design')
+}
+
+android {
+    compileSdkVersion project.ext.currentSdk
+
+    defaultConfig {
+        minSdkVersion 9
+    }
+
+    sourceSets {
+        main.manifest.srcFile 'AndroidManifest.xml'
+        main.java.srcDirs = ['src']
+        main.aidl.srcDirs = ['src']
+        main.res.srcDirs = ['res']
+    }
+
+    lintOptions {
+        // TODO: fix errors and reenable.
+        abortOnError false
+    }
+
+    compileOptions {
+        sourceCompatibility JavaVersion.VERSION_1_7
+        targetCompatibility JavaVersion.VERSION_1_7
+    }
+}
+
diff --git a/samples/SupportLeanbackDemos/build.gradle b/samples/SupportLeanbackDemos/build.gradle
new file mode 100644
index 0000000..c94d41a
--- /dev/null
+++ b/samples/SupportLeanbackDemos/build.gradle
@@ -0,0 +1,31 @@
+apply plugin: 'com.android.application'
+
+dependencies {
+    compile project(':support-leanback-v17')
+}
+
+android {
+    compileSdkVersion project.ext.currentSdk
+
+    defaultConfig {
+        minSdkVersion 17
+    }
+
+    sourceSets {
+        main.manifest.srcFile 'AndroidManifest.xml'
+        main.java.srcDirs = ['src']
+        main.aidl.srcDirs = ['src']
+        main.res.srcDirs = ['res']
+    }
+
+    lintOptions {
+        // TODO: fix errors and reenable.
+        abortOnError false
+    }
+
+    compileOptions {
+        sourceCompatibility JavaVersion.VERSION_1_7
+        targetCompatibility JavaVersion.VERSION_1_7
+    }
+}
+
diff --git a/samples/SupportPercentDemos/build.gradle b/samples/SupportPercentDemos/build.gradle
new file mode 100644
index 0000000..a31b343
--- /dev/null
+++ b/samples/SupportPercentDemos/build.gradle
@@ -0,0 +1,31 @@
+apply plugin: 'com.android.application'
+
+dependencies {
+    compile project(':support-percent')
+}
+
+android {
+    compileSdkVersion project.ext.currentSdk
+
+    defaultConfig {
+        minSdkVersion 11
+    }
+
+    sourceSets {
+        main.manifest.srcFile 'AndroidManifest.xml'
+        main.java.srcDirs = ['src']
+        main.aidl.srcDirs = ['src']
+        main.res.srcDirs = ['res']
+    }
+
+    lintOptions {
+        // TODO: fix errors and reenable.
+        abortOnError false
+    }
+
+    compileOptions {
+        sourceCompatibility JavaVersion.VERSION_1_7
+        targetCompatibility JavaVersion.VERSION_1_7
+    }
+}
+
diff --git a/samples/SupportTransitionDemos/build.gradle b/samples/SupportTransitionDemos/build.gradle
new file mode 100644
index 0000000..c3131ff0
--- /dev/null
+++ b/samples/SupportTransitionDemos/build.gradle
@@ -0,0 +1,32 @@
+apply plugin: 'com.android.application'
+
+dependencies {
+    compile project(':support-transition')
+    compile project(':support-appcompat-v7')
+}
+
+android {
+    compileSdkVersion project.ext.currentSdk
+
+    defaultConfig {
+        minSdkVersion 14
+    }
+
+    sourceSets {
+        main.manifest.srcFile 'AndroidManifest.xml'
+        main.java.srcDirs = ['src']
+        main.aidl.srcDirs = ['src']
+        main.res.srcDirs = ['res']
+    }
+
+    lintOptions {
+        // TODO: fix errors and reenable.
+        abortOnError false
+    }
+
+    compileOptions {
+        sourceCompatibility JavaVersion.VERSION_1_7
+        targetCompatibility JavaVersion.VERSION_1_7
+    }
+}
+
diff --git a/settings.gradle b/settings.gradle
index 12775d0..252b10d 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -1,4 +1,11 @@
 apply from:'buildSrc/studioCompat.gradle'
+
+/////////////////////////////
+//
+// Libraries
+//
+/////////////////////////////
+
 include ':support-annotations'
 project(':support-annotations').projectDir = new File(rootDir, 'annotations')
 
@@ -77,3 +84,32 @@
 include ':support-transition'
 project(':support-transition').projectDir = new File(rootDir, 'transition')
 
+
+/////////////////////////////
+//
+// Samples
+//
+/////////////////////////////
+
+File samplesRoot = new File(rootDir, 'samples')
+
+include ':support-design-demos'
+project(':support-design-demos').projectDir = new File(samplesRoot, 'SupportDesignDemos')
+
+include ':support-leanback-demos'
+project(':support-leanback-demos').projectDir = new File(samplesRoot, 'SupportLeanbackDemos')
+
+include ':support-percent-demos'
+project(':support-percent-demos').projectDir = new File(samplesRoot, 'SupportPercentDemos')
+
+include ':support-transition-demos'
+project(':support-transition-demos').projectDir = new File(samplesRoot, 'SupportTransitionDemos')
+
+include ':support-v4-demos'
+project(':support-v4-demos').projectDir = new File(samplesRoot, 'Support4Demos')
+
+include ':support-v7-demos'
+project(':support-v7-demos').projectDir = new File(samplesRoot, 'Support7Demos')
+
+include ':support-v13-demos'
+project(':support-v13-demos').projectDir = new File(samplesRoot, 'Support13Demos')