Merge "78121: lintOptions quiet=true should also disable status messages" into studio-1.0-dev
diff --git a/build-system/builder-model/src/main/java/com/android/builder/model/BuildType.java b/build-system/builder-model/src/main/java/com/android/builder/model/BuildType.java
index 704df48..c0ecd3f 100644
--- a/build-system/builder-model/src/main/java/com/android/builder/model/BuildType.java
+++ b/build-system/builder-model/src/main/java/com/android/builder/model/BuildType.java
@@ -58,7 +58,7 @@
      *
      * @return true if the apk is debuggable
      */
-    boolean isJniDebugBuild();
+    boolean isJniDebuggable();
 
     /**
      * Returns whether the build type is configured to generate an apk with debuggable
@@ -66,7 +66,7 @@
      *
      * @return true if the apk is debuggable
      */
-    boolean isRenderscriptDebugBuild();
+    boolean isRenderscriptDebuggable();
 
     /**
      * Returns the optimization level of the renderscript compilation.
@@ -104,7 +104,7 @@
      *
      * @return true if zipalign is enabled.
      */
-    boolean isZipAlign();
+    boolean isZipAlignEnabled();
 
     /**
      * Returns whether the variant embeds the micro app.
diff --git a/build-system/builder-model/src/main/java/com/android/builder/model/ProductFlavor.java b/build-system/builder-model/src/main/java/com/android/builder/model/ProductFlavor.java
index d3fdc5c..16a424d 100644
--- a/build-system/builder-model/src/main/java/com/android/builder/model/ProductFlavor.java
+++ b/build-system/builder-model/src/main/java/com/android/builder/model/ProductFlavor.java
@@ -108,20 +108,16 @@
      * make it compatible with older versions of Android.
      *
      * @return true if support mode is enabled, false if not, and null if not specified.
-     *
-     * TODO STOPSHIP: use enums instead of boolean
      */
     @Nullable
-    Boolean getRenderscriptSupportMode();
+    Boolean getRenderscriptSupportModeEnabled();
 
     /**
      * Returns whether the renderscript code should be compiled to generate C/C++ bindings.
      * @return true for C/C++ generation, false for Java, null if not specified.
-     *
-     * TODO STOPSHIP: use enums instead of boolean
      */
     @Nullable
-    Boolean getRenderscriptNdkMode();
+    Boolean getRenderscriptNdkModeEnabled();
 
     /**
      * Returns the test application id. This is only the value set on this product flavor.
diff --git a/build-system/builder/src/main/java/com/android/builder/core/AndroidBuilder.java b/build-system/builder/src/main/java/com/android/builder/core/AndroidBuilder.java
index 8802d0b..ea07d84 100644
--- a/build-system/builder/src/main/java/com/android/builder/core/AndroidBuilder.java
+++ b/build-system/builder/src/main/java/com/android/builder/core/AndroidBuilder.java
@@ -78,6 +78,7 @@
 import com.google.common.base.Strings;
 import com.google.common.collect.ArrayListMultimap;
 import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Iterables;
 import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
 import com.google.common.collect.Multimap;
@@ -125,7 +126,7 @@
 
     private static final FullRevision MIN_BUILD_TOOLS_REV = new FullRevision(19, 1, 0);
     private static final FullRevision MIN_MULTIDEX_BUILD_TOOLS_REV = new FullRevision(21, 0, 0);
-
+    private static final FullRevision MIN_BUILD_TOOLS_REVISION_FOR_DEX_INPUT_LIST = new FullRevision(21, 0, 0);
     private static final DependencyFileProcessor sNoOpDependencyFileProcessor = new DependencyFileProcessor() {
         @Override
         public DependencyData processFile(@NonNull File dependencyFile) {
@@ -355,7 +356,7 @@
     public Set<File> getCompileClasspath(@NonNull VariantConfiguration<?,?,?> variantConfiguration) {
         Set<File> compileClasspath = variantConfiguration.getCompileClasspath();
 
-        if (variantConfiguration.getRenderscriptSupportMode()) {
+        if (variantConfiguration.getRenderscriptSupportModeEnabled()) {
             File renderScriptSupportJar = getRenderScriptSupportJar();
 
             Set<File> fullJars = Sets.newHashSetWithExpectedSize(compileClasspath.size() + 1);
@@ -381,7 +382,7 @@
     public Set<File> getPackagedJars(@NonNull VariantConfiguration<?,?,?> variantConfiguration) {
         Set<File> packagedJars = Sets.newHashSet(variantConfiguration.getPackagedJars());
 
-        if (variantConfiguration.getRenderscriptSupportMode()) {
+        if (variantConfiguration.getRenderscriptSupportModeEnabled()) {
             File renderScriptSupportJar = getRenderScriptSupportJar();
 
             if (renderScriptSupportJar != null) {
@@ -1349,12 +1350,15 @@
                      boolean multidex,
             @NonNull DexOptions dexOptions,
             @Nullable List<String> additionalParameters,
+            @NonNull File tmpFolder,
             boolean incremental) throws IOException, InterruptedException, LoggedErrorException {
         checkNotNull(inputs, "inputs cannot be null.");
         checkNotNull(preDexedLibraries, "preDexedLibraries cannot be null.");
         checkNotNull(outDexFolder, "outDexFolder cannot be null.");
         checkNotNull(dexOptions, "dexOptions cannot be null.");
+        checkNotNull(tmpFolder, "tmpFolder cannot be null");
         checkArgument(outDexFolder.isDirectory(), "outDexFolder must be a folder");
+        checkArgument(tmpFolder.isDirectory(), "tmpFolder must be a folder");
         checkState(mTargetInfo != null,
                 "Cannot call convertByteCode() before setTargetInfo() is called.");
 
@@ -1413,35 +1417,35 @@
         command.add("--output");
         command.add(outDexFolder.getAbsolutePath());
 
-        // clean up input list
-        List<String> inputList = Lists.newArrayList();
-        for (File f : inputs) {
-            if (f != null && f.exists()) {
-                inputList.add(f.getAbsolutePath());
-            }
-        }
-
-        if (!inputList.isEmpty()) {
-            mLogger.verbose("Dex inputs: " + inputList);
-            command.addAll(inputList);
-        }
-
-        // clean up and add library inputs.
-        List<String> libraryList = Lists.newArrayList();
-        for (File f : preDexedLibraries) {
-            if (f != null && f.exists()) {
-                libraryList.add(f.getAbsolutePath());
-            }
-        }
-
-        if (!libraryList.isEmpty()) {
-            mLogger.verbose("Dex pre-dexed inputs: " + libraryList);
-            command.addAll(libraryList);
-        }
+        Iterable<File> allInputs = Iterables.concat(preDexedLibraries, inputs);
+        command.addAll(getFilesToAdd(allInputs, buildToolInfo, tmpFolder));
 
         mCmdLineRunner.runCmdLine(command, null);
     }
 
+    private List<String> getFilesToAdd(Iterable<File> includeFiles,
+            BuildToolInfo buildToolInfo, File tmpFolder) throws IOException {
+        // clean up and add library inputs.
+        List<String> filePathList = Lists.newArrayList();
+        for (File f : includeFiles) {
+            if (f != null && f.exists()) {
+                filePathList.add(f.getAbsolutePath());
+            }
+        }
+        if (filePathList.isEmpty()) {
+            throw new IOException("No files to pass to dex.");
+        }
+
+        if (buildToolInfo.getRevision().compareTo(MIN_BUILD_TOOLS_REVISION_FOR_DEX_INPUT_LIST) >= 0) {
+            File inputListFile = new File(tmpFolder, "libraryList.txt");
+            // Write each library line by line to file
+            Files.asCharSink(inputListFile, Charsets.UTF_8).writeLines(filePathList);
+            return Lists.newArrayList("--input-list=" + inputListFile.getAbsolutePath());
+        } else {
+            return filePathList;
+        }
+    }
+
     /**
      * Converts the bytecode to Dalvik format
      * @param inputFile the input file
diff --git a/build-system/builder/src/main/java/com/android/builder/core/DefaultBuildType.java b/build-system/builder/src/main/java/com/android/builder/core/DefaultBuildType.java
index 5d365cd..1cc970d 100644
--- a/build-system/builder/src/main/java/com/android/builder/core/DefaultBuildType.java
+++ b/build-system/builder/src/main/java/com/android/builder/core/DefaultBuildType.java
@@ -29,8 +29,8 @@
     private final String mName;
     private boolean mDebuggable = false;
     private boolean mTestCoverageEnabled = false;
-    private boolean mJniDebugBuild = false;
-    private boolean mRenderscriptDebugBuild = false;
+    private boolean mJniDebuggable = false;
+    private boolean mRenderscriptDebuggable = false;
     private int mRenderscriptOptimLevel = 3;
     private String mApplicationIdSuffix = null;
     private String mVersionNameSuffix = null;
@@ -38,7 +38,7 @@
     private SigningConfig mSigningConfig = null;
     private boolean mEmbedMicroApp = true;
 
-    private boolean mZipAlign = true;
+    private boolean mZipAlignEnabled = true;
 
     public DefaultBuildType(@NonNull String name) {
         mName = name;
@@ -49,13 +49,13 @@
 
         setDebuggable(that.isDebuggable());
         setTestCoverageEnabled(that.isTestCoverageEnabled());
-        setJniDebugBuild(that.isJniDebugBuild());
-        setRenderscriptDebugBuild(that.isRenderscriptDebugBuild());
+        setJniDebuggable(that.isJniDebuggable());
+        setRenderscriptDebuggable(that.isRenderscriptDebuggable());
         setRenderscriptOptimLevel(that.getRenderscriptOptimLevel());
         setApplicationIdSuffix(that.getApplicationIdSuffix());
         setVersionNameSuffix(that.getVersionNameSuffix());
         setMinifyEnabled(that.isMinifyEnabled() );
-        setZipAlign(that.isZipAlign());
+        setZipAlignEnabled(that.isZipAlignEnabled());
         setSigningConfig(that.getSigningConfig());
         setEmbedMicroApp(that.isEmbedMicroApp());
 
@@ -94,26 +94,27 @@
      * Whether this build type is configured to generate an APK with debuggable native code.
      */
     @NonNull
-    public BuildType setJniDebugBuild(boolean jniDebugBuild) {
-        mJniDebugBuild = jniDebugBuild;
+    public BuildType setJniDebuggable(boolean jniDebugBuild) {
+        mJniDebuggable = jniDebugBuild;
         return this;
     }
 
     @Override
-    public boolean isJniDebugBuild() {
-        return mJniDebugBuild;
+    public boolean isJniDebuggable() {
+        return mJniDebuggable;
     }
 
     @Override
-    public boolean isRenderscriptDebugBuild() {
-        return mRenderscriptDebugBuild;
+    public boolean isRenderscriptDebuggable() {
+        return mRenderscriptDebuggable;
     }
 
     /**
      * Whether the build type is configured to generate an apk with debuggable RenderScript code.
      */
-    public void setRenderscriptDebugBuild(boolean renderscriptDebugBuild) {
-        mRenderscriptDebugBuild = renderscriptDebugBuild;
+    public BuildType setRenderscriptDebuggable(boolean renderscriptDebugBuild) {
+        mRenderscriptDebuggable = renderscriptDebugBuild;
+        return this;
     }
 
     @Override
@@ -166,16 +167,17 @@
         return mMinifyEnabled;
     }
 
+
     /** Whether zipalign is enabled for this build type. */
     @NonNull
-    public BuildType setZipAlign(boolean zipAlign) {
-        mZipAlign = zipAlign;
+    public BuildType setZipAlignEnabled(boolean zipAlign) {
+        mZipAlignEnabled = zipAlign;
         return this;
     }
 
     @Override
-    public boolean isZipAlign() {
-        return mZipAlign;
+    public boolean isZipAlignEnabled() {
+        return mZipAlignEnabled;
     }
 
     /** Sets the signing configuration. e.g.: {@code signingConfig signingConfigs.myConfig} */
@@ -211,11 +213,11 @@
         if (!mName.equals(buildType.mName)) return false;
         if (mDebuggable != buildType.mDebuggable) return false;
         if (mTestCoverageEnabled != buildType.mTestCoverageEnabled) return false;
-        if (mJniDebugBuild != buildType.mJniDebugBuild) return false;
-        if (mRenderscriptDebugBuild != buildType.mRenderscriptDebugBuild) return false;
+        if (mJniDebuggable != buildType.mJniDebuggable) return false;
+        if (mRenderscriptDebuggable != buildType.mRenderscriptDebuggable) return false;
         if (mRenderscriptOptimLevel != buildType.mRenderscriptOptimLevel) return false;
         if (mMinifyEnabled != buildType.mMinifyEnabled) return false;
-        if (mZipAlign != buildType.mZipAlign) return false;
+        if (mZipAlignEnabled != buildType.mZipAlignEnabled) return false;
         if (mApplicationIdSuffix != null ?
                 !mApplicationIdSuffix.equals(buildType.mApplicationIdSuffix) :
                 buildType.mApplicationIdSuffix != null)
@@ -239,13 +241,13 @@
         result = 31 * result + (mName.hashCode());
         result = 31 * result + (mDebuggable ? 1 : 0);
         result = 31 * result + (mTestCoverageEnabled ? 1 : 0);
-        result = 31 * result + (mJniDebugBuild ? 1 : 0);
-        result = 31 * result + (mRenderscriptDebugBuild ? 1 : 0);
+        result = 31 * result + (mJniDebuggable ? 1 : 0);
+        result = 31 * result + (mRenderscriptDebuggable ? 1 : 0);
         result = 31 * result + mRenderscriptOptimLevel;
         result = 31 * result + (mApplicationIdSuffix != null ? mApplicationIdSuffix.hashCode() : 0);
         result = 31 * result + (mVersionNameSuffix != null ? mVersionNameSuffix.hashCode() : 0);
         result = 31 * result + (mMinifyEnabled ? 1 : 0);
-        result = 31 * result + (mZipAlign ? 1 : 0);
+        result = 31 * result + (mZipAlignEnabled ? 1 : 0);
         result = 31 * result + (mSigningConfig != null ? mSigningConfig.hashCode() : 0);
         result = 31 * result + (mEmbedMicroApp ? 1 : 0);
         return result;
@@ -258,13 +260,13 @@
                 .add("name", mName)
                 .add("debuggable", mDebuggable)
                 .add("testCoverageEnabled", mTestCoverageEnabled)
-                .add("jniDebugBuild", mJniDebugBuild)
-                .add("renderscriptDebugBuild", mRenderscriptDebugBuild)
+                .add("jniDebuggable", mJniDebuggable)
+                .add("renderscriptDebuggable", mRenderscriptDebuggable)
                 .add("renderscriptOptimLevel", mRenderscriptOptimLevel)
                 .add("applicationIdSuffix", mApplicationIdSuffix)
                 .add("versionNameSuffix", mVersionNameSuffix)
-                .add("minify", mMinifyEnabled)
-                .add("zipAlign", mZipAlign)
+                .add("minifyEnabled", mMinifyEnabled)
+                .add("zipAlignEnabled", mZipAlignEnabled)
                 .add("signingConfig", mSigningConfig)
                 .add("embedMicroApp", mEmbedMicroApp)
                 .add("mBuildConfigFields", getBuildConfigFields())
diff --git a/build-system/builder/src/main/java/com/android/builder/core/DefaultProductFlavor.java b/build-system/builder/src/main/java/com/android/builder/core/DefaultProductFlavor.java
index 6fb3670..4cade4c 100644
--- a/build-system/builder/src/main/java/com/android/builder/core/DefaultProductFlavor.java
+++ b/build-system/builder/src/main/java/com/android/builder/core/DefaultProductFlavor.java
@@ -43,8 +43,8 @@
     private ApiVersion mTargetSdkVersion;
     private Integer mMaxSdkVersion;
     private Integer mRenderscriptTargetApi;
-    private Boolean mRenderscriptSupportMode;
-    private Boolean mRenderscriptNdkMode;
+    private Boolean mRenderscriptSupportModeEnabled;
+    private Boolean mRenderscriptNdkModeEnabled;
     private Integer mVersionCode;
     private String mVersionName;
     private String mApplicationId;
@@ -175,27 +175,30 @@
 
     @Override
     @Nullable
-    public Boolean getRenderscriptSupportMode() {
-        return mRenderscriptSupportMode;
+    public Boolean getRenderscriptSupportModeEnabled() {
+        return mRenderscriptSupportModeEnabled;
     }
 
     /**
      * Sets whether the renderscript code should be compiled in support mode to make it compatible
      * with older versions of Android.
      */
-    public void setRenderscriptSupportMode(Boolean renderscriptSupportMode) {
-        mRenderscriptSupportMode = renderscriptSupportMode;
+    public ProductFlavor setRenderscriptSupportModeEnabled(Boolean renderscriptSupportMode) {
+        mRenderscriptSupportModeEnabled = renderscriptSupportMode;
+        return this;
     }
 
     @Override
     @Nullable
-    public Boolean getRenderscriptNdkMode() {
-        return mRenderscriptNdkMode;
+    public Boolean getRenderscriptNdkModeEnabled() {
+        return mRenderscriptNdkModeEnabled;
     }
 
+
     /** Sets whether the renderscript code should be compiled to generate C/C++ bindings. */
-    public void setRenderscriptNdkMode(Boolean renderscriptNdkMode) {
-        mRenderscriptNdkMode = renderscriptNdkMode;
+    public ProductFlavor setRenderscriptNdkModeEnabled(Boolean renderscriptNdkMode) {
+        mRenderscriptNdkModeEnabled = renderscriptNdkMode;
+        return this;
     }
 
     /** Sets the test package name. */
@@ -323,12 +326,12 @@
         flavor.mRenderscriptTargetApi = chooseNotNull(
                 overlay.getRenderscriptTargetApi(),
                 base.getRenderscriptTargetApi());
-        flavor.mRenderscriptSupportMode = chooseNotNull(
-                overlay.getRenderscriptSupportMode(),
-                base.getRenderscriptSupportMode());
-        flavor.mRenderscriptNdkMode = chooseNotNull(
-                overlay.getRenderscriptNdkMode(),
-                base.getRenderscriptNdkMode());
+        flavor.mRenderscriptSupportModeEnabled = chooseNotNull(
+                overlay.getRenderscriptSupportModeEnabled(),
+                base.getRenderscriptSupportModeEnabled());
+        flavor.mRenderscriptNdkModeEnabled = chooseNotNull(
+                overlay.getRenderscriptNdkModeEnabled(),
+                base.getRenderscriptNdkModeEnabled());
 
         flavor.mVersionCode = chooseNotNull(overlay.getVersionCode(), base.getVersionCode());
         flavor.mVersionName = chooseNotNull(overlay.getVersionName(), base.getVersionName());
@@ -388,8 +391,8 @@
         flavor.mTargetSdkVersion = productFlavor.getTargetSdkVersion();
         flavor.mMaxSdkVersion = productFlavor.getMaxSdkVersion();
         flavor.mRenderscriptTargetApi = productFlavor.getRenderscriptTargetApi();
-        flavor.mRenderscriptSupportMode = productFlavor.getRenderscriptSupportMode();
-        flavor.mRenderscriptNdkMode = productFlavor.getRenderscriptNdkMode();
+        flavor.mRenderscriptSupportModeEnabled = productFlavor.getRenderscriptSupportModeEnabled();
+        flavor.mRenderscriptNdkModeEnabled = productFlavor.getRenderscriptNdkModeEnabled();
 
         flavor.mVersionCode = productFlavor.getVersionCode();
         flavor.mVersionName = productFlavor.getVersionName();
@@ -447,12 +450,14 @@
         if (!mName.equals(that.mName)) {
             return false;
         }
-        if (mRenderscriptNdkMode != null ? !mRenderscriptNdkMode.equals(that.mRenderscriptNdkMode)
-                : that.mRenderscriptNdkMode != null) {
+        if (mRenderscriptNdkModeEnabled != null ? !mRenderscriptNdkModeEnabled
+                .equals(that.mRenderscriptNdkModeEnabled)
+                : that.mRenderscriptNdkModeEnabled != null) {
             return false;
         }
-        if (mRenderscriptSupportMode != null ? !mRenderscriptSupportMode
-                .equals(that.mRenderscriptSupportMode) : that.mRenderscriptSupportMode != null) {
+        if (mRenderscriptSupportModeEnabled != null ? !mRenderscriptSupportModeEnabled
+                .equals(that.mRenderscriptSupportModeEnabled) : that.mRenderscriptSupportModeEnabled
+                != null) {
             return false;
         }
         if (mRenderscriptTargetApi != null ? !mRenderscriptTargetApi
@@ -511,10 +516,10 @@
         result = 31 * result + (mMaxSdkVersion != null ? mMaxSdkVersion.hashCode() : 0);
         result = 31 * result + (mRenderscriptTargetApi != null ? mRenderscriptTargetApi.hashCode()
                 : 0);
-        result = 31 * result + (mRenderscriptSupportMode != null ? mRenderscriptSupportMode
+        result = 31 * result + (mRenderscriptSupportModeEnabled != null ? mRenderscriptSupportModeEnabled
                 .hashCode()
                 : 0);
-        result = 31 * result + (mRenderscriptNdkMode != null ? mRenderscriptNdkMode.hashCode() : 0);
+        result = 31 * result + (mRenderscriptNdkModeEnabled != null ? mRenderscriptNdkModeEnabled.hashCode() : 0);
         result = 31 * result + (mVersionCode != null ? mVersionCode.hashCode() : 0);
         result = 31 * result + (mVersionName != null ? mVersionName.hashCode() : 0);
         result = 31 * result + (mApplicationId != null ? mApplicationId.hashCode() : 0);
@@ -537,8 +542,8 @@
                 .add("minSdkVersion", mMinSdkVersion)
                 .add("targetSdkVersion", mTargetSdkVersion)
                 .add("renderscriptTargetApi", mRenderscriptTargetApi)
-                .add("renderscriptSupportMode", mRenderscriptSupportMode)
-                .add("renderscriptNdkMode", mRenderscriptNdkMode)
+                .add("renderscriptSupportModeEnabled", mRenderscriptSupportModeEnabled)
+                .add("renderscriptNdkModeEnabled", mRenderscriptNdkModeEnabled)
                 .add("versionCode", mVersionCode)
                 .add("versionName", mVersionName)
                 .add("applicationId", mApplicationId)
diff --git a/build-system/builder/src/main/java/com/android/builder/core/VariantConfiguration.java b/build-system/builder/src/main/java/com/android/builder/core/VariantConfiguration.java
index be1a6e8..471a8e7 100644
--- a/build-system/builder/src/main/java/com/android/builder/core/VariantConfiguration.java
+++ b/build-system/builder/src/main/java/com/android/builder/core/VariantConfiguration.java
@@ -1718,8 +1718,8 @@
     /**
      * Returns the renderscript support mode.
      */
-    public boolean getRenderscriptSupportMode() {
-        Boolean value = mMergedFlavor.getRenderscriptSupportMode();
+    public boolean getRenderscriptSupportModeEnabled() {
+        Boolean value = mMergedFlavor.getRenderscriptSupportModeEnabled();
         if (value != null) {
             return value;
         }
@@ -1731,8 +1731,8 @@
     /**
      * Returns the renderscript NDK mode.
      */
-    public boolean getRenderscriptNdkMode() {
-        Boolean value = mMergedFlavor.getRenderscriptNdkMode();
+    public boolean getRenderscriptNdkModeEnabled() {
+        Boolean value = mMergedFlavor.getRenderscriptNdkModeEnabled();
         if (value != null) {
             return value;
         }
diff --git a/build-system/gradle/src/integ-test/groovy/com/android/build/gradle/NdkVariantIntegTest.groovy b/build-system/gradle/src/integ-test/groovy/com/android/build/gradle/NdkVariantIntegTest.groovy
index 973630a..7cea5ce 100644
--- a/build-system/gradle/src/integ-test/groovy/com/android/build/gradle/NdkVariantIntegTest.groovy
+++ b/build-system/gradle/src/integ-test/groovy/com/android/build/gradle/NdkVariantIntegTest.groovy
@@ -56,7 +56,7 @@
     buildTypes {
         release
         debug {
-            jniDebugBuild true
+            jniDebuggable true
         }
     }
     productFlavors {
diff --git a/build-system/gradle/src/main/groovy/com/android/build/gradle/BasePlugin.groovy b/build-system/gradle/src/main/groovy/com/android/build/gradle/BasePlugin.groovy
index c8a6f8d..0a95422 100755
--- a/build-system/gradle/src/main/groovy/com/android/build/gradle/BasePlugin.groovy
+++ b/build-system/gradle/src/main/groovy/com/android/build/gradle/BasePlugin.groovy
@@ -823,7 +823,7 @@
         }
 
         ProductFlavor mergedFlavor = config.mergedFlavor
-        boolean ndkMode = config.renderscriptNdkMode
+        boolean ndkMode = config.renderscriptNdkModeEnabled
 
         variantData.resourceGenTask.dependsOn renderscriptTask
         // only put this dependency if rs will generate Java code
@@ -850,9 +850,9 @@
             return targetApi
         }
 
-        renderscriptTask.supportMode = config.renderscriptSupportMode
+        renderscriptTask.supportMode = config.renderscriptSupportModeEnabled
         renderscriptTask.ndkMode = ndkMode
-        renderscriptTask.debugBuild = config.buildType.renderscriptDebugBuild
+        renderscriptTask.debugBuild = config.buildType.renderscriptDebuggable
         renderscriptTask.optimLevel = config.buildType.renderscriptOptimLevel
 
         renderscriptTask.conventionMapping.sourceDirs = { config.renderscriptSourceList }
@@ -1373,7 +1373,7 @@
 
         VariantConfiguration variantConfig = variantData.variantConfiguration
 
-        if (variantConfig.mergedFlavor.renderscriptNdkMode) {
+        if (variantConfig.mergedFlavor.renderscriptNdkModeEnabled) {
             ndkCompile.ndkRenderScriptMode = true
             ndkCompile.dependsOn variantData.renderscriptCompileTask
         } else {
@@ -1382,7 +1382,7 @@
 
         ndkCompile.conventionMapping.sourceFolders = {
             List<File> sourceList = variantConfig.jniSourceList
-            if (variantConfig.mergedFlavor.renderscriptNdkMode) {
+            if (variantConfig.mergedFlavor.renderscriptNdkModeEnabled) {
                 sourceList.add(variantData.renderscriptCompileTask.sourceOutputDir)
             }
 
@@ -1396,7 +1396,7 @@
         ndkCompile.conventionMapping.ndkConfig = { variantConfig.ndkConfig }
 
         ndkCompile.conventionMapping.debuggable = {
-            variantConfig.buildType.jniDebugBuild
+            variantConfig.buildType.jniDebuggable
         }
 
         ndkCompile.conventionMapping.objFolder = {
@@ -1860,6 +1860,8 @@
             config.isMultiDexEnabled()
         }
 
+        dexTask.tmpFolder = project.file("$project.buildDir/${FD_INTERMEDIATES}/tmp/dex/${config.dirName}")
+
         JacocoInstrumentTask jacocoTask = null
         Copy agentTask = null
         File jacocoAgentJar = null
@@ -2202,7 +2204,7 @@
                 set.addAll(config.libraryJniFolders)
                 set.addAll(config.jniLibsList)
 
-                if (config.mergedFlavor.renderscriptSupportMode) {
+                if (config.mergedFlavor.renderscriptSupportModeEnabled) {
                     File rsLibs = androidBuilder.getSupportNativeLibFolder()
                     if (rsLibs != null && rsLibs.isDirectory()) {
                         set.add(rsLibs);
@@ -2217,7 +2219,7 @@
                 }
                 return config.supportedAbis
             }
-            packageApp.conventionMapping.jniDebugBuild = { config.buildType.jniDebugBuild }
+            packageApp.conventionMapping.jniDebugBuild = { config.buildType.jniDebuggable }
 
             packageApp.conventionMapping.signingConfig = { sc }
             if (sc != null) {
@@ -2244,7 +2246,7 @@
             packageApp.conventionMapping.outputFile = {
                 // if this is the final task then the location is
                 // the potentially overridden one.
-                if (!signedApk || !variantData.zipAlign) {
+                if (!signedApk || !variantData.zipAlignEnabled) {
                     project.file("$apkLocation/${apkName}")
                 } else {
                     // otherwise default one.
@@ -2256,7 +2258,7 @@
             OutputFileTask outputFileTask = packageApp
 
             if (signedApk) {
-                if (variantData.zipAlign) {
+                if (variantData.zipAlignEnabled) {
                     // Add a task to zip align application package
                     def zipAlignTask = project.tasks.create(
                             "zipalign${outputName.capitalize()}",
diff --git a/build-system/gradle/src/main/groovy/com/android/build/gradle/internal/VariantManager.java b/build-system/gradle/src/main/groovy/com/android/build/gradle/internal/VariantManager.java
index eb9d45b..d4e9ae4 100644
--- a/build-system/gradle/src/main/groovy/com/android/build/gradle/internal/VariantManager.java
+++ b/build-system/gradle/src/main/groovy/com/android/build/gradle/internal/VariantManager.java
@@ -49,12 +49,14 @@
 import com.android.build.gradle.internal.variant.VariantFactory;
 import com.android.builder.core.VariantConfiguration;
 import com.android.builder.model.BuildType;
+import com.android.builder.model.ProductFlavor;
 import com.android.builder.model.SigningConfig;
 import com.google.common.base.Function;
 import com.google.common.collect.Iterables;
 import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
 
+import org.gradle.api.GradleException;
 import org.gradle.api.NamedDomainObjectContainer;
 import org.gradle.api.Project;
 import org.gradle.api.Task;
@@ -70,7 +72,7 @@
 /**
  * Class to create, manage variants.
  */
-public class VariantManager {
+public class VariantManager implements VariantModel {
 
     @NonNull
     private final Project project;
@@ -107,16 +109,19 @@
         this.variantFactory = variantFactory;
     }
 
+    @Override
     @NonNull
     public Map<String, BuildTypeData> getBuildTypes() {
         return buildTypes;
     }
 
+    @Override
     @NonNull
     public Map<String, ProductFlavorData<GroupableProductFlavorDsl>> getProductFlavors() {
         return productFlavors;
     }
 
+    @Override
     @NonNull
     public Map<String, SigningConfig> getSigningConfigs() {
         return signingConfigs;
@@ -188,6 +193,8 @@
      * Task creation entry point.
      */
     public void createAndroidTasks(@Nullable SigningConfig signingOverride) {
+        variantFactory.validateModel(this);
+
         if (!productFlavors.isEmpty()) {
             // there'll be more than one test app, so we need a top level assembleTest
             Task assembleTest = project.getTasks().create("assembleTest");
@@ -486,10 +493,12 @@
             /// add the container of dependencies
             // the order of the libraries is important. In descending order:
             // flavors, defaultConfig. No build type for tests
-            List<ConfigurationProvider> testVariantProviders = Lists.newArrayListWithExpectedSize(1 + productFlavorList.size());
+            List<ConfigurationProvider> testVariantProviders = Lists
+                    .newArrayListWithExpectedSize(1 + productFlavorList.size());
 
             for (GroupableProductFlavor productFlavor : productFlavorList) {
-                ProductFlavorData<GroupableProductFlavorDsl> data = productFlavors.get(productFlavor.getName());
+                ProductFlavorData<GroupableProductFlavorDsl> data = productFlavors
+                        .get(productFlavor.getName());
 
                 String dimensionName = productFlavor.getFlavorDimension();
                 if (dimensionName == null) {
diff --git a/build-system/gradle/src/main/groovy/com/android/build/gradle/internal/VariantModel.java b/build-system/gradle/src/main/groovy/com/android/build/gradle/internal/VariantModel.java
new file mode 100644
index 0000000..ce99610
--- /dev/null
+++ b/build-system/gradle/src/main/groovy/com/android/build/gradle/internal/VariantModel.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2014 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.
+ */
+
+package com.android.build.gradle.internal;
+
+import com.android.annotations.NonNull;
+import com.android.build.gradle.internal.dsl.GroupableProductFlavorDsl;
+import com.android.builder.model.SigningConfig;
+
+import java.util.Map;
+
+/**
+ * Provides information about the build types, product flavors and signing configurations.
+ */
+public interface VariantModel {
+    @NonNull
+    public Map<String, BuildTypeData> getBuildTypes();
+
+    @NonNull
+    public Map<String, ProductFlavorData<GroupableProductFlavorDsl>> getProductFlavors();
+
+    @NonNull
+    public Map<String, SigningConfig> getSigningConfigs();
+}
diff --git a/build-system/gradle/src/main/groovy/com/android/build/gradle/internal/api/ApkVariantImpl.java b/build-system/gradle/src/main/groovy/com/android/build/gradle/internal/api/ApkVariantImpl.java
index d887591..5485a31 100644
--- a/build-system/gradle/src/main/groovy/com/android/build/gradle/internal/api/ApkVariantImpl.java
+++ b/build-system/gradle/src/main/groovy/com/android/build/gradle/internal/api/ApkVariantImpl.java
@@ -123,12 +123,12 @@
         // if more than one output, refuse to use this method
         if (outputs.size() > 1) {
             throw new RuntimeException(String.format(
-                    "More than one output on variant '%s', cannot call getZipAlign() on it. Call it on one of its outputs instead.",
+                    "More than one output on variant '%s', cannot call getZipAlignEnabled() on it. Call it on one of its outputs instead.",
                     getName()));
         }
 
         // deprecation warning.
-        plugin.displayDeprecationWarning("variant.getZipAlign() is deprecated. Call it on one of variant.getOutputs() instead.");
+        plugin.displayDeprecationWarning("variant.getZipAlignEnabled() is deprecated. Call it on one of variant.getOutputs() instead.");
 
         // use the single output for compatibility.
         return ((ApkVariantOutputImpl) outputs.get(0)).getZipAlign();
diff --git a/build-system/gradle/src/main/groovy/com/android/build/gradle/internal/api/ReadOnlyBuildType.java b/build-system/gradle/src/main/groovy/com/android/build/gradle/internal/api/ReadOnlyBuildType.java
index 35a41d7..9817880 100644
--- a/build-system/gradle/src/main/groovy/com/android/build/gradle/internal/api/ReadOnlyBuildType.java
+++ b/build-system/gradle/src/main/groovy/com/android/build/gradle/internal/api/ReadOnlyBuildType.java
@@ -61,13 +61,13 @@
     }
 
     @Override
-    public boolean isJniDebugBuild() {
-        return buildType.isJniDebugBuild();
+    public boolean isJniDebuggable() {
+        return buildType.isJniDebuggable();
     }
 
     @Override
-    public boolean isRenderscriptDebugBuild() {
-        return buildType.isRenderscriptDebugBuild();
+    public boolean isRenderscriptDebuggable() {
+        return buildType.isRenderscriptDebuggable();
     }
 
     @Override
@@ -93,8 +93,8 @@
     }
 
     @Override
-    public boolean isZipAlign() {
-        return buildType.isZipAlign();
+    public boolean isZipAlignEnabled() {
+        return buildType.isZipAlignEnabled();
     }
 
     @Override
diff --git a/build-system/gradle/src/main/groovy/com/android/build/gradle/internal/api/ReadOnlyProductFlavor.java b/build-system/gradle/src/main/groovy/com/android/build/gradle/internal/api/ReadOnlyProductFlavor.java
index 8b3496b..4cfb0c6 100644
--- a/build-system/gradle/src/main/groovy/com/android/build/gradle/internal/api/ReadOnlyProductFlavor.java
+++ b/build-system/gradle/src/main/groovy/com/android/build/gradle/internal/api/ReadOnlyProductFlavor.java
@@ -97,14 +97,14 @@
 
     @Nullable
     @Override
-    public Boolean getRenderscriptSupportMode() {
-        return productFlavor.getRenderscriptSupportMode();
+    public Boolean getRenderscriptSupportModeEnabled() {
+        return productFlavor.getRenderscriptSupportModeEnabled();
     }
 
     @Nullable
     @Override
-    public Boolean getRenderscriptNdkMode() {
-        return productFlavor.getRenderscriptNdkMode();
+    public Boolean getRenderscriptNdkModeEnabled() {
+        return productFlavor.getRenderscriptNdkModeEnabled();
     }
 
     @Nullable
diff --git a/build-system/gradle/src/main/groovy/com/android/build/gradle/internal/dsl/BuildTypeDsl.groovy b/build-system/gradle/src/main/groovy/com/android/build/gradle/internal/dsl/BuildTypeDsl.groovy
index bc66186..a26851c 100644
--- a/build-system/gradle/src/main/groovy/com/android/build/gradle/internal/dsl/BuildTypeDsl.groovy
+++ b/build-system/gradle/src/main/groovy/com/android/build/gradle/internal/dsl/BuildTypeDsl.groovy
@@ -19,6 +19,7 @@
 import com.android.annotations.Nullable
 import com.android.annotations.VisibleForTesting
 import com.android.build.gradle.tasks.ShrinkResources
+import com.android.build.gradle.BasePlugin
 import com.android.builder.core.AndroidBuilder
 import com.android.builder.core.BuilderConstants
 import com.android.builder.core.DefaultBuildType
@@ -191,14 +192,14 @@
     }
 
     public BuildType setRunProguard(boolean enabled) {
-        logger.warn("WARNING: runProguard is deprecated (and will soon stop working); change to \"minifyEnabled\" instead");
+        BasePlugin.displayDeprecationWarning(logger, project, "WARNING: runProguard is deprecated (and will soon stop working); change to \"minifyEnabled\" instead");
         return setMinifyEnabled(enabled)
     }
 
     /** Package name suffix applied to this build type. */
     @NonNull
     public BuildType setPackageNameSuffix(@Nullable String packageNameSuffix) {
-        logger.warn("WARNING: packageNameSuffix is deprecated (and will soon stop working); change to \"applicationIdSuffix\" instead");
+        BasePlugin.displayDeprecationWarning(logger, project, "WARNING: packageNameSuffix is deprecated (and will soon stop working); change to \"applicationIdSuffix\" instead");
         return setApplicationIdSuffix(packageNameSuffix);
     }
 
@@ -209,7 +210,31 @@
 
     @Nullable
     public String getPackageNameSuffix() {
-        logger.warn("WARNING: packageNameSuffix is deprecated (and will soon stop working); change to \"applicationIdSuffix\" instead");
+        BasePlugin.displayDeprecationWarning(logger, project, "WARNING: packageNameSuffix is deprecated (and will soon stop working); change to \"applicationIdSuffix\" instead");
         return getApplicationIdSuffix();
     }
+
+    /**
+     * Whether this build type is configured to generate an APK with debuggable native code.
+     */
+    @NonNull
+    public BuildType setJniDebugBuild(boolean jniDebugBuild) {
+        BasePlugin.displayDeprecationWarning(logger, project, "WARNING: jniDebugBuild is deprecated (and will soon stop working); change to \"jniDebuggable\" instead");
+        return super.setJniDebuggable(jniDebugBuild);
+    }
+
+    /**
+     * Whether the build type is configured to generate an apk with debuggable RenderScript code.
+     */
+    public BuildType setRenderscriptDebugBuild(boolean renderscriptDebugBuild) {
+        BasePlugin.displayDeprecationWarning(logger, project, "WARNING: renderscriptDebugBuild is deprecated (and will soon stop working); change to \"renderscriptDebuggable\" instead");
+        return setRenderscriptDebuggable(renderscriptDebugBuild);
+    }
+
+    /** Whether zipalign is enabled for this build type. */
+    @NonNull
+    public BuildType setZipAlign(boolean zipAlign) {
+        BasePlugin.displayDeprecationWarning(logger, project, "WARNING: zipAlign is deprecated (and will soon stop working); change to \"zipAlignEnabled\" instead");
+        return setZipAlignEnabled(zipAlign);
+    }
 }
diff --git a/build-system/gradle/src/main/groovy/com/android/build/gradle/internal/dsl/ProductFlavorDsl.groovy b/build-system/gradle/src/main/groovy/com/android/build/gradle/internal/dsl/ProductFlavorDsl.groovy
index 63c2f72..1c88cb9 100644
--- a/build-system/gradle/src/main/groovy/com/android/build/gradle/internal/dsl/ProductFlavorDsl.groovy
+++ b/build-system/gradle/src/main/groovy/com/android/build/gradle/internal/dsl/ProductFlavorDsl.groovy
@@ -37,6 +37,7 @@
 
     @NonNull
     protected final Project project
+
     @NonNull
     protected final Logger logger
 
@@ -45,9 +46,9 @@
     private Boolean useJack
 
     ProductFlavorDsl(@NonNull String name,
-                     @NonNull Project project,
-                     @NonNull Instantiator instantiator,
-                     @NonNull Logger logger) {
+            @NonNull Project project,
+            @NonNull Instantiator instantiator,
+            @NonNull Logger logger) {
         super(name)
         this.project = project
         this.logger = logger
@@ -216,6 +217,7 @@
     void resConfigs(@NonNull String... config) {
         addResourceConfigurations(config);
     }
+
     void resConfigs(@NonNull Collection<String> config) {
         addResourceConfigurations(config);
     }
@@ -244,7 +246,8 @@
      */
     @NonNull
     public ProductFlavor setPackageName(String packageName) {
-        BasePlugin.displayDeprecationWarning(logger, project, "\"packageName\" is deprecated (and will soon stop working); change to \"applicationId\" instead");
+        BasePlugin.displayDeprecationWarning(logger, project,
+                "\"packageName\" is deprecated (and will soon stop working); change to \"applicationId\" instead");
         return setApplicationId(packageName);
     }
 
@@ -255,19 +258,40 @@
 
     @Nullable
     public String getPackageName() {
-        BasePlugin.displayDeprecationWarning(logger, project, "\"packageName\" is deprecated (and will soon stop working); change to \"applicationId\" instead");
+        BasePlugin.displayDeprecationWarning(logger, project,
+                "\"packageName\" is deprecated (and will soon stop working); change to \"applicationId\" instead");
         return getApplicationId();
     }
 
     @Nullable
     public String getTestPackageName() {
-        BasePlugin.displayDeprecationWarning(logger, project, "\"testPackageName\" is deprecated (and will soon stop working); change to \"testApplicationId\" instead");
+        BasePlugin.displayDeprecationWarning(logger, project,
+                "\"testPackageName\" is deprecated (and will soon stop working); change to \"testApplicationId\" instead");
         return getTestApplicationId();
     }
 
     @Nullable
     public ProductFlavor setTestPackageName(String packageName) {
-        BasePlugin.displayDeprecationWarning(logger, project, "\"testPackageName\" is deprecated (and will soon stop working); change to \"testApplicationId\" instead");
+        BasePlugin.displayDeprecationWarning(logger, project,
+                "\"testPackageName\" is deprecated (and will soon stop working); change to \"testApplicationId\" instead");
         return setTestApplicationId(packageName);
     }
-}
+
+    /**
+     * Sets whether the renderscript code should be compiled in support mode to make it compatible
+     * with older versions of Android.
+     */
+    public ProductFlavor setRenderscriptSupportMode(Boolean renderscriptSupportMode) {
+        BasePlugin.displayDeprecationWarning(logger, project,
+                "\"renderscriptSupportMode\" is deprecated (and will soon stop working); change to \"renderscriptSupportModeEnabled\" instead");
+        return setRenderscriptNdkModeEnabled(renderscriptSupportMode);
+    }
+
+    /** Sets whether the renderscript code should be compiled to generate C/C++ bindings. */
+    public ProductFlavor setRenderscriptNdkMode(Boolean renderscriptNdkMode) {
+        BasePlugin.displayDeprecationWarning(logger, project,
+                "\"renderscriptNdkMode\" is deprecated (and will soon stop working); change to \"renderscriptNdkModeEnabled\" instead");
+
+        return super.setRenderscriptNdkModeEnabled(renderscriptNdkMode);
+    }
+}
\ No newline at end of file
diff --git a/build-system/gradle/src/main/groovy/com/android/build/gradle/internal/model/BuildTypeImpl.java b/build-system/gradle/src/main/groovy/com/android/build/gradle/internal/model/BuildTypeImpl.java
index 3888bed..62dbc0f 100644
--- a/build-system/gradle/src/main/groovy/com/android/build/gradle/internal/model/BuildTypeImpl.java
+++ b/build-system/gradle/src/main/groovy/com/android/build/gradle/internal/model/BuildTypeImpl.java
@@ -33,13 +33,13 @@
     private String name;
     private boolean debuggable;
     private boolean testCoverageEnabled;
-    private boolean jniDebugBuild;
-    private boolean renderscriptDebugBuild;
+    private boolean jniDebuggable;
+    private boolean renderscriptDebuggable;
     private int renderscriptOptimLevel;
     private String applicationIdSuffix;
     private String versionNameSuffix;
     private boolean minifyEnabled;
-    private boolean zipAlign;
+    private boolean zipAlignEnabled;
     private boolean embedMicroApp;
 
     @NonNull
@@ -49,13 +49,13 @@
         clonedBuildType.name = buildType.getName();
         clonedBuildType.debuggable = buildType.isDebuggable();
         clonedBuildType.testCoverageEnabled = buildType.isTestCoverageEnabled();
-        clonedBuildType.jniDebugBuild = buildType.isJniDebugBuild();
-        clonedBuildType.renderscriptDebugBuild = buildType.isRenderscriptDebugBuild();
+        clonedBuildType.jniDebuggable = buildType.isJniDebuggable();
+        clonedBuildType.renderscriptDebuggable = buildType.isRenderscriptDebuggable();
         clonedBuildType.renderscriptOptimLevel = buildType.getRenderscriptOptimLevel();
         clonedBuildType.applicationIdSuffix = buildType.getApplicationIdSuffix();
         clonedBuildType.versionNameSuffix = buildType.getVersionNameSuffix();
         clonedBuildType.minifyEnabled = buildType.isMinifyEnabled();
-        clonedBuildType.zipAlign = buildType.isZipAlign();
+        clonedBuildType.zipAlignEnabled = buildType.isZipAlignEnabled();
         clonedBuildType.embedMicroApp = buildType.isEmbedMicroApp();
 
         return clonedBuildType;
@@ -82,13 +82,13 @@
     }
 
     @Override
-    public boolean isJniDebugBuild() {
-        return jniDebugBuild;
+    public boolean isJniDebuggable() {
+        return jniDebuggable;
     }
 
     @Override
-    public boolean isRenderscriptDebugBuild() {
-        return renderscriptDebugBuild;
+    public boolean isRenderscriptDebuggable() {
+        return renderscriptDebuggable;
     }
 
     @Override
@@ -114,8 +114,8 @@
     }
 
     @Override
-    public boolean isZipAlign() {
-        return zipAlign;
+    public boolean isZipAlignEnabled() {
+        return zipAlignEnabled;
     }
 
     @Override
@@ -135,13 +135,13 @@
                 "name='" + name + '\'' +
                 ", debuggable=" + debuggable +
                 ", testCoverageEnabled=" + testCoverageEnabled +
-                ", jniDebugBuild=" + jniDebugBuild +
-                ", renderscriptDebugBuild=" + renderscriptDebugBuild +
+                ", jniDebuggable=" + jniDebuggable +
+                ", renderscriptDebuggable=" + renderscriptDebuggable +
                 ", renderscriptOptimLevel=" + renderscriptOptimLevel +
                 ", applicationIdSuffix='" + applicationIdSuffix + '\'' +
                 ", versionNameSuffix='" + versionNameSuffix + '\'' +
                 ", minifyEnabled=" + minifyEnabled +
-                ", zipAlign=" + zipAlign +
+                ", zipAlignEnabled=" + zipAlignEnabled +
                 ", embedMicroApp=" + embedMicroApp +
                 "} " + super.toString();
     }
diff --git a/build-system/gradle/src/main/groovy/com/android/build/gradle/internal/model/DependenciesImpl.java b/build-system/gradle/src/main/groovy/com/android/build/gradle/internal/model/DependenciesImpl.java
index 1fdca1d..c3e2077 100644
--- a/build-system/gradle/src/main/groovy/com/android/build/gradle/internal/model/DependenciesImpl.java
+++ b/build-system/gradle/src/main/groovy/com/android/build/gradle/internal/model/DependenciesImpl.java
@@ -117,7 +117,7 @@
         GradleVariantConfiguration variantConfig = variantData.getVariantConfiguration();
         AndroidBuilder androidBuilder = basePlugin.getAndroidBuilder();
 
-        if (variantConfig.getRenderscriptSupportMode()) {
+        if (variantConfig.getRenderscriptSupportModeEnabled()) {
             File supportJar = androidBuilder.getRenderScriptSupportJar();
             if (supportJar != null) {
                 javaLibraries.add(new JavaLibraryImpl(supportJar, null, null));
diff --git a/build-system/gradle/src/main/groovy/com/android/build/gradle/internal/model/ModelBuilder.groovy b/build-system/gradle/src/main/groovy/com/android/build/gradle/internal/model/ModelBuilder.groovy
index a4b0880..5bbff29 100644
--- a/build-system/gradle/src/main/groovy/com/android/build/gradle/internal/model/ModelBuilder.groovy
+++ b/build-system/gradle/src/main/groovy/com/android/build/gradle/internal/model/ModelBuilder.groovy
@@ -18,11 +18,9 @@
 import com.android.annotations.NonNull
 import com.android.annotations.Nullable
 import com.android.build.OutputFile
-import com.android.build.gradle.AppPlugin
 import com.android.build.gradle.BasePlugin
 import com.android.build.gradle.LibraryPlugin
 import com.android.build.gradle.api.ApkOutputFile
-import com.android.build.gradle.api.MainApkOutputFile
 import com.android.build.gradle.internal.BuildTypeData
 import com.android.build.gradle.internal.ProductFlavorData
 import com.android.build.gradle.internal.dsl.LintOptionsImpl
@@ -50,9 +48,7 @@
 import com.google.common.collect.ImmutableCollection
 import com.google.common.collect.ImmutableList
 import com.google.common.collect.Lists
-import com.google.common.util.concurrent.Callables
 import org.gradle.api.Project
-import org.gradle.api.plugins.UnknownPluginException
 import org.gradle.api.tasks.compile.AbstractCompile
 import org.gradle.tooling.provider.model.ToolingModelBuilder
 
@@ -334,7 +330,7 @@
 
         folders.add(variantData.aidlCompileTask.sourceOutputDir)
         folders.add(variantData.generateBuildConfigTask.sourceOutputDir)
-        if (!variantData.variantConfiguration.mergedFlavor.renderscriptNdkMode) {
+        if (!variantData.variantConfiguration.mergedFlavor.renderscriptNdkModeEnabled) {
             folders.add(variantData.renderscriptCompileTask.sourceOutputDir)
         }
 
diff --git a/build-system/gradle/src/main/groovy/com/android/build/gradle/internal/model/ProductFlavorImpl.java b/build-system/gradle/src/main/groovy/com/android/build/gradle/internal/model/ProductFlavorImpl.java
index 830f992..4e70b5e 100644
--- a/build-system/gradle/src/main/groovy/com/android/build/gradle/internal/model/ProductFlavorImpl.java
+++ b/build-system/gradle/src/main/groovy/com/android/build/gradle/internal/model/ProductFlavorImpl.java
@@ -68,8 +68,8 @@
                 ? null /* we remove the maxSdkVersion when dealing with a preview release */
                 : productFlavor.getMaxSdkVersion();
         clonedFlavor.mRenderscriptTargetApi = productFlavor.getRenderscriptTargetApi();
-        clonedFlavor.mRenderscriptSupportMode = productFlavor.getRenderscriptSupportMode();
-        clonedFlavor.mRenderscriptNdkMode = productFlavor.getRenderscriptNdkMode();
+        clonedFlavor.mRenderscriptSupportMode = productFlavor.getRenderscriptSupportModeEnabled();
+        clonedFlavor.mRenderscriptNdkMode = productFlavor.getRenderscriptNdkModeEnabled();
 
         clonedFlavor.mVersionCode = productFlavor.getVersionCode();
         clonedFlavor.mVersionName = productFlavor.getVersionName();
@@ -139,13 +139,13 @@
 
     @Override
     @Nullable
-    public Boolean getRenderscriptSupportMode() {
+    public Boolean getRenderscriptSupportModeEnabled() {
         return mRenderscriptSupportMode;
     }
 
     @Override
     @Nullable
-    public Boolean getRenderscriptNdkMode() {
+    public Boolean getRenderscriptNdkModeEnabled() {
         return mRenderscriptNdkMode;
     }
 
diff --git a/build-system/gradle/src/main/groovy/com/android/build/gradle/internal/variant/ApkVariantData.java b/build-system/gradle/src/main/groovy/com/android/build/gradle/internal/variant/ApkVariantData.java
index 27ffe1e..ae5b26b 100644
--- a/build-system/gradle/src/main/groovy/com/android/build/gradle/internal/variant/ApkVariantData.java
+++ b/build-system/gradle/src/main/groovy/com/android/build/gradle/internal/variant/ApkVariantData.java
@@ -67,7 +67,7 @@
         return getVariantConfiguration().isSigningReady();
     }
 
-    public boolean getZipAlign() {
-        return getVariantConfiguration().getBuildType().isZipAlign();
+    public boolean getZipAlignEnabled() {
+        return getVariantConfiguration().getBuildType().isZipAlignEnabled();
     }
 }
diff --git a/build-system/gradle/src/main/groovy/com/android/build/gradle/internal/variant/ApplicationVariantFactory.java b/build-system/gradle/src/main/groovy/com/android/build/gradle/internal/variant/ApplicationVariantFactory.java
index 3ef119e..480a72e 100644
--- a/build-system/gradle/src/main/groovy/com/android/build/gradle/internal/variant/ApplicationVariantFactory.java
+++ b/build-system/gradle/src/main/groovy/com/android/build/gradle/internal/variant/ApplicationVariantFactory.java
@@ -23,6 +23,9 @@
 import com.android.build.gradle.BasePlugin;
 import com.android.build.gradle.api.BaseVariant;
 import com.android.build.gradle.api.BaseVariantOutput;
+import com.android.build.gradle.internal.BuildTypeData;
+import com.android.build.gradle.internal.ProductFlavorData;
+import com.android.build.gradle.internal.VariantModel;
 import com.android.build.gradle.internal.api.ReadOnlyObjectProvider;
 import com.android.build.gradle.internal.api.ApkVariantImpl;
 import com.android.build.gradle.internal.api.ApkVariantOutputImpl;
@@ -38,6 +41,7 @@
 import java.io.File;
 import java.util.Collections;
 import java.util.List;
+import java.util.Map;
 import java.util.Set;
 
 /**
@@ -204,6 +208,11 @@
         basePlugin.createPackagingTask(appVariantData, assembleTask, true /*publishApk*/);
     }
 
+    @Override
+    public void validateModel(VariantModel model){
+        // No additional checks for ApplicationVariantFactory, so just return.
+    }
+
     private void handleMicroApp(@NonNull BaseVariantData<?> variantData) {
 
         Configuration config = basePlugin.getProject().getConfigurations().findByName(
diff --git a/build-system/gradle/src/main/groovy/com/android/build/gradle/internal/variant/BaseVariantData.java b/build-system/gradle/src/main/groovy/com/android/build/gradle/internal/variant/BaseVariantData.java
index 8721fd6..81f5a40 100644
--- a/build-system/gradle/src/main/groovy/com/android/build/gradle/internal/variant/BaseVariantData.java
+++ b/build-system/gradle/src/main/groovy/com/android/build/gradle/internal/variant/BaseVariantData.java
@@ -268,7 +268,7 @@
             // for the other, there's no duplicate so no issue.
             sourceList.add(generateBuildConfigTask.getSourceOutputDir());
             sourceList.add(aidlCompileTask.getSourceOutputDir());
-            if (!variantConfiguration.getRenderscriptNdkMode()) {
+            if (!variantConfiguration.getRenderscriptNdkModeEnabled()) {
                 sourceList.add(renderscriptCompileTask.getSourceOutputDir());
             }
 
@@ -306,7 +306,7 @@
             sourceFolders.add(sourceFolder);
         }
 
-        if (!variantConfiguration.getRenderscriptNdkMode()) {
+        if (!variantConfiguration.getRenderscriptNdkModeEnabled()) {
             sourceFolder = renderscriptCompileTask.getSourceOutputDir();
             if (sourceFolder.isDirectory()) {
                 sourceFolders.add(sourceFolder);
diff --git a/build-system/gradle/src/main/groovy/com/android/build/gradle/internal/variant/LibraryVariantFactory.groovy b/build-system/gradle/src/main/groovy/com/android/build/gradle/internal/variant/LibraryVariantFactory.groovy
index e26d181..f1004fe 100644
--- a/build-system/gradle/src/main/groovy/com/android/build/gradle/internal/variant/LibraryVariantFactory.groovy
+++ b/build-system/gradle/src/main/groovy/com/android/build/gradle/internal/variant/LibraryVariantFactory.groovy
@@ -22,6 +22,9 @@
 import com.android.build.gradle.LibraryExtension
 import com.android.build.gradle.api.BaseVariant
 import com.android.build.gradle.api.BaseVariantOutput
+import com.android.build.gradle.internal.BuildTypeData
+import com.android.build.gradle.internal.ProductFlavorData
+import com.android.build.gradle.internal.VariantModel
 import com.android.build.gradle.internal.api.LibraryVariantImpl
 import com.android.build.gradle.internal.api.LibraryVariantOutputImpl
 import com.android.build.gradle.internal.api.ReadOnlyObjectProvider
@@ -40,6 +43,7 @@
 import com.android.builder.model.AndroidLibrary
 import com.android.builder.model.MavenCoordinates
 import com.google.common.collect.Lists
+import org.gradle.api.GradleException
 import org.gradle.api.Project
 import org.gradle.api.Task
 import org.gradle.api.tasks.Copy
@@ -437,4 +441,28 @@
 
         return task
     }
+
+    /***
+     * Prevent customization of applicationId or applicationIdSuffix.
+     */
+    @Override
+    public void validateModel(VariantModel model) {
+        for (BuildTypeData buildType : model.getBuildTypes().values()) {
+            if (buildType.getBuildType().getApplicationIdSuffix() != null) {
+                throw new GradleException("Library projects cannot set applicationId. " +
+                        "applicationIdSuffix is set to '" +
+                        buildType.getBuildType().getApplicationIdSuffix() +
+                        "' in build type '" + buildType.getBuildType().getName() + "'.");
+            }
+        }
+        for (ProductFlavorData productFlavor : model.getProductFlavors().values()) {
+            if (productFlavor.getProductFlavor().getApplicationId() != null) {
+                throw new GradleException("Library projects cannot set applicationId. " +
+                        "applicationId is set to '" +
+                        productFlavor.getProductFlavor().getApplicationId() + "' in flavor '" +
+                        productFlavor.getProductFlavor().getName() + "'.");
+            }
+        }
+
+    }
 }
diff --git a/build-system/gradle/src/main/groovy/com/android/build/gradle/internal/variant/TestVariantData.java b/build-system/gradle/src/main/groovy/com/android/build/gradle/internal/variant/TestVariantData.java
index 0fee005..3c9bc62 100644
--- a/build-system/gradle/src/main/groovy/com/android/build/gradle/internal/variant/TestVariantData.java
+++ b/build-system/gradle/src/main/groovy/com/android/build/gradle/internal/variant/TestVariantData.java
@@ -66,7 +66,7 @@
     }
 
     @Override
-    public boolean getZipAlign() {
+    public boolean getZipAlignEnabled() {
         return false;
     }
 }
diff --git a/build-system/gradle/src/main/groovy/com/android/build/gradle/internal/variant/VariantFactory.java b/build-system/gradle/src/main/groovy/com/android/build/gradle/internal/variant/VariantFactory.java
index edad4c3..294c654 100644
--- a/build-system/gradle/src/main/groovy/com/android/build/gradle/internal/variant/VariantFactory.java
+++ b/build-system/gradle/src/main/groovy/com/android/build/gradle/internal/variant/VariantFactory.java
@@ -19,12 +19,16 @@
 import com.android.annotations.NonNull;
 import com.android.annotations.Nullable;
 import com.android.build.gradle.api.BaseVariant;
+import com.android.build.gradle.internal.BuildTypeData;
+import com.android.build.gradle.internal.ProductFlavorData;
+import com.android.build.gradle.internal.VariantModel;
 import com.android.build.gradle.internal.api.ReadOnlyObjectProvider;
 import com.android.build.gradle.internal.core.GradleVariantConfiguration;
 import com.android.builder.core.VariantConfiguration;
 
 import org.gradle.api.Task;
 
+import java.util.Map;
 import java.util.Set;
 
 /**
@@ -60,4 +64,11 @@
     void createTasks(
             @NonNull BaseVariantData<?> variantData,
             @Nullable Task assembleTask);
+
+    /**
+     * Fail if the model is configured incorrectly.
+     * @param model the non-null model to validate, as implemented by the VariantManager.
+     * @throws org.gradle.api.GradleException when the model does not validate.
+     */
+    void validateModel(@NonNull VariantModel model);
 }
diff --git a/build-system/gradle/src/main/groovy/com/android/build/gradle/tasks/Dex.groovy b/build-system/gradle/src/main/groovy/com/android/build/gradle/tasks/Dex.groovy
index 5274b4f..5919393 100644
--- a/build-system/gradle/src/main/groovy/com/android/build/gradle/tasks/Dex.groovy
+++ b/build-system/gradle/src/main/groovy/com/android/build/gradle/tasks/Dex.groovy
@@ -53,6 +53,8 @@
     @Input
     boolean multiDex = false
 
+    File tmpFolder
+
     /**
      * Actual entry point for the action.
      * Calls out to the doTaskAction as needed.
@@ -96,11 +98,13 @@
 
     private void doTaskAction(boolean incremental) {
         File outFolder = getOutputFolder()
-
         if (!incremental) {
             emptyFolder(outFolder)
         }
 
+        File tmpFolder = getTmpFolder()
+        tmpFolder.mkdirs()
+
         getBuilder().convertByteCode(
                 getInputFiles(),
                 getLibraries(),
@@ -108,6 +112,7 @@
                 getMultiDex(),
                 getDexOptions(),
                 getAdditionalParameters(),
+                tmpFolder,
                 incremental)
     }
 }
diff --git a/build-system/gradle/src/test/groovy/com/android/build/gradle/AppPluginDslTest.groovy b/build-system/gradle/src/test/groovy/com/android/build/gradle/AppPluginDslTest.groovy
index a6efa68..7216d2b 100644
--- a/build-system/gradle/src/test/groovy/com/android/build/gradle/AppPluginDslTest.groovy
+++ b/build-system/gradle/src/test/groovy/com/android/build/gradle/AppPluginDslTest.groovy
@@ -366,7 +366,7 @@
             assertNotNull(variant.install)
 
             // tested variant are never zipAligned.
-            if (!isTestVariant && variant.buildType.zipAlign) {
+            if (!isTestVariant && variant.buildType.zipAlignEnabled) {
                 assertNotNull(variant.zipAlign)
             } else {
                 assertNull(variant.zipAlign)
diff --git a/build-system/gradle/src/test/groovy/com/android/build/gradle/internal/dsl/BuildTypeDslTest.groovy b/build-system/gradle/src/test/groovy/com/android/build/gradle/internal/dsl/BuildTypeDslTest.groovy
index 48f9c81..e72a362 100644
--- a/build-system/gradle/src/test/groovy/com/android/build/gradle/internal/dsl/BuildTypeDslTest.groovy
+++ b/build-system/gradle/src/test/groovy/com/android/build/gradle/internal/dsl/BuildTypeDslTest.groovy
@@ -43,11 +43,11 @@
         DefaultBuildType type = plugin.variantManager.buildTypes.get(BuilderConstants.DEBUG).buildType
 
         assertTrue(type.isDebuggable())
-        assertFalse(type.isJniDebugBuild())
-        assertFalse(type.isRenderscriptDebugBuild())
+        assertFalse(type.isJniDebuggable())
+        assertFalse(type.isRenderscriptDebuggable())
         assertNotNull(type.getSigningConfig())
         assertTrue(type.getSigningConfig().isSigningReady())
-        assertTrue(type.isZipAlign())
+        assertTrue(type.isZipAlignEnabled())
     }
 
     public void testRelease() {
@@ -65,9 +65,9 @@
         DefaultBuildType type = plugin.variantManager.buildTypes.get(BuilderConstants.RELEASE).buildType
 
         assertFalse(type.isDebuggable())
-        assertFalse(type.isJniDebugBuild())
-        assertFalse(type.isRenderscriptDebugBuild())
-        assertTrue(type.isZipAlign())
+        assertFalse(type.isJniDebuggable())
+        assertFalse(type.isRenderscriptDebuggable())
+        assertTrue(type.isZipAlignEnabled())
     }
 
     public void testInitWith() {
@@ -78,14 +78,14 @@
 
         // change every value from their default.
         object1.setDebuggable(true)
-        object1.setJniDebugBuild(true)
-        object1.setRenderscriptDebugBuild(true)
+        object1.setJniDebuggable(true)
+        object1.setRenderscriptDebuggable(true)
         object1.setRenderscriptOptimLevel(0)
         object1.setPackageNameSuffix("foo")
         object1.setVersionNameSuffix("foo")
         object1.setMinifyEnabled(true)
         object1.setSigningConfig(new SigningConfigDsl("blah"))
-        object1.setZipAlign(false)
+        object1.setZipAlignEnabled(false)
 
         BuildTypeDsl object2 = new BuildTypeDsl(object1.name, project, project.getLogger())
         object2.initWith(object1)
diff --git a/build-system/tests/native/ndkRsHelloCompute/build.gradle b/build-system/tests/native/ndkRsHelloCompute/build.gradle
index efb0655..f16439d 100644
--- a/build-system/tests/native/ndkRsHelloCompute/build.gradle
+++ b/build-system/tests/native/ndkRsHelloCompute/build.gradle
@@ -32,7 +32,7 @@
 
     }
 
-    buildTypes.debug.jniDebugBuild true
+    buildTypes.debug.jniDebuggable true
 
     productFlavors {
         x86 {
diff --git a/build-system/tests/native/ndkSanAngeles2/build.gradle b/build-system/tests/native/ndkSanAngeles2/build.gradle
index 239f0e3..f14e602 100644
--- a/build-system/tests/native/ndkSanAngeles2/build.gradle
+++ b/build-system/tests/native/ndkSanAngeles2/build.gradle
@@ -28,7 +28,7 @@
         versionCode = 123
     }
 
-    buildTypes.debug.jniDebugBuild true
+    buildTypes.debug.jniDebuggable true
 
     useNewNativePlugin = true
     ndk {
diff --git a/build-system/tests/native/ndkStl/build.gradle b/build-system/tests/native/ndkStl/build.gradle
index 7750d25..c9988a9 100644
--- a/build-system/tests/native/ndkStl/build.gradle
+++ b/build-system/tests/native/ndkStl/build.gradle
@@ -32,7 +32,7 @@
             moduleName "hello-jni"
         }
 
-        buildTypes.debug.jniDebugBuild true
+        buildTypes.debug.jniDebuggable true
 
         sourceSets {
             androidTest {
diff --git a/build-system/tests/regular/extractRsEnabledAnnotations/build.gradle b/build-system/tests/regular/extractRsEnabledAnnotations/build.gradle
index e1a7fa1..f717d9e 100644
--- a/build-system/tests/regular/extractRsEnabledAnnotations/build.gradle
+++ b/build-system/tests/regular/extractRsEnabledAnnotations/build.gradle
@@ -33,6 +33,6 @@
         minSdkVersion 14
         targetSdkVersion 19
         renderscriptTargetApi 18
-        renderscriptSupportMode true
+        renderscriptSupportModeEnabled true
    }
 }
diff --git a/build-system/tests/regular/ndkSanAngeles/build.gradle b/build-system/tests/regular/ndkSanAngeles/build.gradle
index 4e41fca..4987bfe 100644
--- a/build-system/tests/regular/ndkSanAngeles/build.gradle
+++ b/build-system/tests/regular/ndkSanAngeles/build.gradle
@@ -36,7 +36,7 @@
 
     }
 
-    buildTypes.debug.jniDebugBuild true
+    buildTypes.debug.jniDebuggable true
 
     splits {
         abi {
diff --git a/build-system/tests/regular/renamedApk/build.gradle b/build-system/tests/regular/renamedApk/build.gradle
index fea2af2..64c3b11 100644
--- a/build-system/tests/regular/renamedApk/build.gradle
+++ b/build-system/tests/regular/renamedApk/build.gradle
@@ -27,7 +27,7 @@
     buildToolsVersion = rootProject.ext.buildToolsVersion
 
     buildTypes.debug {
-        zipAlign true
+        zipAlignEnabled true
     }
 }
 
diff --git a/build-system/tests/regular/rsSupportMode/build.gradle b/build-system/tests/regular/rsSupportMode/build.gradle
index 9c892aa..3aaaccc 100644
--- a/build-system/tests/regular/rsSupportMode/build.gradle
+++ b/build-system/tests/regular/rsSupportMode/build.gradle
@@ -26,7 +26,7 @@
         minSdkVersion 8
         targetSdkVersion 16
         renderscriptTargetApi 18
-        renderscriptSupportMode true
+        renderscriptSupportModeEnabled true
     }
 
     productFlavors {