Adarsh Fernando ed81d75081 Docs: Fixed typo referencing 'Android Plugin for Gradle version' instead of
'Gradle plugin version' + other minor typos.

b/25960585

Change-Id: I6b364c9aec6c1497da37f74e4b68abc56bbbdc72
2016-01-21 16:28:32 -08:00

623 lines
24 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

page.title=Android Plugin for Gradle Release Notes
@jd:body
<div id="qv-wrapper">
<div id="qv">
<h2>See also</h2>
<ol>
<li><a href="{@docRoot}sdk/installing/studio-build.html">Build System Overview</a></li>
<li><a href="{@docRoot}tools/building/plugin-for-gradle.html">Android Plugin for Gradle</a></li>
</ol>
</div>
</div>
<p>The Android build system uses the Android Plugin for Gradle to support building Android
applications with the <a href="http://www.gradle.org/">Gradle</a> build toolkit. The plugin runs
independent of Android Studio so the plugin and the Gradle build system can be updated
independently of Android Studio.</p>
<p class="note"><strong>Note:</strong> When you update Android Studio or open a project in a
previous version of Android Studio, Android Studio prompts you to automatically update the plugin
and Gradle to the latest available versions. You can choose to accept these updates based
on your project's build requirements. </p>
<h2 id="revisions">Revisions</h2>
<p>The sections below provide notes about successive releases of
the Android Plugin for Gradle, as denoted by revision number. To determine what revision of the
plugin you are using, check the version declaration in the project-level
<strong>build.gradle</strong> file. </p>
<p>For a summary of known issues in Android Plugin for Gradle, see <a
href="http://tools.android.com/knownissues">http://tools.android.com/knownissues</a>.</p>
<div class="toggle-content opened">
<p><a href="#" onclick="return toggleContent(this)">
<img src="{@docRoot}assets/images/triangle-opened.png" class="toggle-content-img"
alt=""/>Android Plugin for Gradle, Revision 1.5.0</a> <em>(November 2015)</em>
</p>
<div class="toggle-content-toggleme">
<dl>
<dt>Dependencies:</dt>
<dd>
<ul>
<li>Gradle 2.2.1 or higher.</li>
<li>Build Tools 21.1.1 or higher.</li>
</ul>
</dd>
<dt>General Notes:</dt>
<dd>
<ul>
<li>Integrated the Data Binding Plugin into the Android Plugin for Gradle. To enable it, add
the following code to each per-project <code>build.gradle</code> file that uses the
plugin:</li>
<pre>
android {
dataBinding {
enabled = true
}
}
</pre>
<li>Added a new <a href="http://google.github.io/android-gradle-dsl/javadoc/1.5/" class="external-link">Transform API</a>
to allow third-party plugins to manipulate compiled <code>.class</code> files before theyre
converted to <code>.dex</code> files. The Transform API simplifies injecting custom class
manipulations while offering more flexibility regarding what you can manipulate. To insert a
transform into a build, create a new class implementing one of the <code>Transform</code>
interfaces, and register it with <code>android.registerTransform(theTransform)</code> or
<code>android.registerTransform(theTransform, dependencies)</code>. Theres no need to
wire tasks together. Note the following about the Transform API:</li>
<ul>
<li>A transform can apply to one or more of the following: the current project, subprojects,
and external libraries.</li>
<li>A transform must be registered globally, which applies them to all variants.</li>
<li>Internal code processing, through the Java Code Coverage Library (JaCoCo), ProGuard,
and MultiDex, now uses the Transform API. However, the Java Android Compiler Kit
(Jack) doesnt use this API: only the <code>javac/dx</code> code path does.</li>
<li>Gradle executes the transforms in this order: JaCoCo, third-party plugins, ProGuard.
The execution order for third-party plugins matches the order in which the transforms are
added by the third party plugins; third-party plugin developers can't control the execution
order of the transforms through an API.</li>
</ul>
<li>Deprecated the <code>dex</code> getter from the <code>ApplicationVariant</code> class.
You can't access the <code>Dex</code> task through the variant API anymore because its now
accomplished through a transform. There's
currently no replacement for controlling the dex process.</li>
<li>Fixed incremental support for assets.</li>
<li>Improved MultiDex support by making it available for test projects, and
tests now automatically have the <code>com.android.support:multidex-instrumentation</code>
dependency.</li>
<li>Added the ability to properly fail a Gradle build and report the underlying error cause
when the Gradle build invokes asynchronous tasks and theres a failure in the worker
process.</li>
<li>Added support for configuring a specific Application Binary Interface (ABI) in variants
that contain multiple ABIs.</li>
<li>Added support for a comma-separated list of device serial numbers for the
<code>ANDROID_SERIAL</code> environment variable when installing or running tests.</li>
<li>Fixed an installation failure on devices running Android 5.0 (API level 20) and higher
when the APK name contains a space.</li>
<li>Fixed various issues related to the Android Asset Packaging Tool (AAPT) error output.</li>
<li>Added JaCoCo incremental instrumentation support for faster incremental builds. The
Android Plugin for Gradle now invokes the JaCoCo instrumenter directly. To force a newer
version of the JaCoCo instrumenter, you need to add it as a build script dependency.</li>
<li>Fixed JaCoCo support so it ignores files that arent classes.</li>
<li>Added vector drawable support for generating PNGs at build time for backward-compatibility.
Android Plugin for Gradle generates PNGs for every vector drawable found in a resource
directory that doesnt specify an API version or specifies an
<code>android:minSdkVersion</code> attribute of 20 or lower in the
<code>&lt;uses-sdk&gt;</code> element in the app manifest. You can set PNG densities by
using the <code>generatedDensities</code> property in the <code>defaultConfig</code> or
<code>productFlavor</code> sections of a <code>build.gradle</code> file.</li>
<li>Added sharing of the mockable <code>android.jar</code>, which the plugin generates only
once and uses for unit testing. Multiple modules, such as <code>app</code> and
<code>lib</code>, now share it. Delete <code>$rootDir/build</code> to regenerate it. </li>
<li>Changed the processing of Java resources to occur before the obfuscation tasks instead of
during the packaging of the APK. This change allows the obfuscation tasks to have a chance
to adapt the Java resources following packages obfuscation.</li>
<li>Fixed an issue with using Java Native Interface (JNI) code in the experimental library
plugin.</li>
<li>Added the ability to set the platform version separately from the
<code>android:compileSdkVersion</code> attribute in the experimental library
plugin.</li>
</ul>
</dd>
</div>
</div>
<div class="toggle-content closed">
<p><a href="#" onclick="return toggleContent(this)">
<img src="{@docRoot}assets/images/triangle-closed.png" class="toggle-content-img"
alt=""/>Android Plugin for Gradle, Revision 1.3.1</a> <em>(August 2015)</em>
</p>
<div class="toggle-content-toggleme">
<dl>
<dt>Dependencies:</dt>
<dd>
<ul>
<li>Gradle 2.2.1 or higher.</li>
<li>Build Tools 21.1.1 or higher.</li>
</ul>
</dd>
<dt>General Notes:</dt>
<dd>
<ul>
<li>Fixed the <a href="{@docRoot}tools/help/zipalign.html">ZipAlign</a> task to properly
consume the output of the previous task when using a customized filename. </li>
<li>Fixed <a href="{@docRoot}guide/topics/renderscript/compute.html">Renderscript</a>
packaging with the <a href="{@docRoot}tools/sdk/ndk/index.html">NDK</a>. </li>
<li>Maintained support for the <code>createDebugCoverageReport</code> build task. </li>
<li>Fixed support for customized use of the <code>archiveBaseName</code> property
in the <code>build.gradle</code> build> file. </li>
<li>Fixed the <code>Invalid ResourceType</code>
<a href="{@docRoot}tools/help/lint.html">lint</a> warning caused by parameter method
annotation lookup when running
<a href="{@docRoot}tools/help/lint.html">lint</a> outside of Android Studio.</li>
</ul>
</dd>
</div>
</div>
<div class="toggle-content closed">
<p><a href="#" onclick="return toggleContent(this)">
<img src="{@docRoot}assets/images/triangle-closed.png" class="toggle-content-img"
alt=""/>Android Plugin for Gradle, Revision 1.3.0</a> <em>(July 2015)</em>
</p>
<div class="toggle-content-toggleme">
<dl>
<dt>Dependencies:</dt>
<dd>
<ul>
<li>Gradle 2.2.1 or higher.</li>
<li>Build Tools 21.1.1 or higher.</li>
</ul>
</dd>
<dt>General Notes:</dt>
<dd>
<ul>
<li>Added support for the <code>com.android.build.threadPoolSize</code> property to control
the <code>Android</code> task thread pool size from the <code>gradle.properties</code> file
or the command line. The following example sets this property to 4.
<pre>
-Pcom.android.build.threadPoolSize=4
</pre>
</li>
<li>Set the default build behavior to exclude <code>LICENSE</code> and <code>LICENSE.txt</code>
files from APKs. To include these files in an APK, remove these files from the
<code>packagingOptions.excludes</code> property in the <code>build.gradle</code> file.
For example:
<pre>
android {
packagingOptions.excludes = []
}
</pre>
</li>
<li>Added the <code>sourceSets</code> task to inspect the set of all available source sets. </li>
<li>Enhanced unit test support to recognize multi-flavor and
<a href="{@docRoot}tools/building/configuring-gradle.html#workBuildVariants">
build variant</a> source folders. For example, to test an app with multi-flavors
<code>flavor1</code> and <code>flavorA</code> with the <code>Debug</code> build type,
the test source sets are:
<ul>
<li>test </li>
<li>testFlavor1 </li>
<li>testFlavorA </li>
<li>testFlavor1FlavorA </li>
<li>testFlavor1FlavorADebug </li>
</ul>
<p>Android tests already recognized multi-flavor source folders. </p> </li>
<li>Improved unit test support to:</p>
<ul>
<li>Run <code>javac</code> on main and test sources, even if the <code>useJack</code>
property is set to <code>true</code> in your build file. </li>
<li>Correctly recognize dependencies for each build type. </li>
</ul>
</li>
<li>Added support for specifying instrumentation test-runner arguments from the command line.
For example:
<pre>
./gradlew connectedCheck \
-Pandroid.testInstrumentationRunnerArguments.size=medium \
-Pandroid.testInstrumentationRunnerArguments.class=TestA,TestB
</pre>
</li>
<li>Added support for arbitrary additional Android Asset Packaging Tool (AAPT) parameters
in the <code>build.gradle</code> file. For example:
<pre>
android {
aaptOptions {
additionalParameters "--custom_option", "value"
}
}
</pre>
</li>
<li>Added support for a <a href="{@docRoot}tools/studio/studio-features.html#test-module">
test APK module</a> as a separate test module, using the
<code>targetProjectPath</code> and <code>targetVariant</code> properties to set the APK
path and target variant.
<p class="note"><strong>Note:</strong> A test APK module does not support product
flavors and can only target a single variant. Also, Jacoco is not supported yet.</p>
</li>
<li>Added resource name validation before merging resources. </li>
<li>When building an AAR (Android ARchive) package for library modules, do not provide an
automatic <code>&#64;{applicationId}</code> placeholder in the
<a href="{@docRoot}tools/building/manifest-merge.html">manifest merger</a> settings.
Instead, use a different placeholder, such as <code>&#64;{libApplicationId}</code> and
provide a value for it if you want to include application Ids in the archive library. </li>
</ul>
</dd>
</div>
</div>
<div class="toggle-content closed">
<p><a href="#" onclick="return toggleContent(this)">
<img src="{@docRoot}assets/images/triangle-closed.png" class="toggle-content-img"
alt=""/>Android Plugin for Gradle, Revision 1.2.0</a> <em>(April 2015)</em>
</p>
<div class="toggle-content-toggleme">
<dl>
<dt>Dependencies:</dt>
<dd>
<ul>
<li>Gradle 2.2.1 or higher.</li>
<li>Build Tools 21.1.1 or higher.</li>
</ul>
</dd>
<dt>General Notes:</dt>
<dd>
<ul>
<li>Enhanced support for running unit tests with Gradle. </li>
<ul>
<li>Added support to include Java-style resources in the classpath when running unit
tests directly from Gradle.
</li>
<li>Added unit test dependency support for Android ARchive (AAR) artifacts.
</li>
<li>Added support for the <code>unitTestVariants</code> property so unit test variants
can be manipulated using the <code>build.gradle</code> file.
</li>
<li>Added the <code>unitTest.all</code> code block under <code>testOptions</code> to
configure customized tasks for unit test. The following sample code shows how to add
unit test configuration settings using this new option:
<pre>
android {
testOptions {
unitTest.all {
jvmArgs '-XX:MaxPermSize=256m' // Or any other gradle option.
}
}
}
</pre>
</li>
<li>Fixed the handling of enums and public instance fields in the packaging of the
<code>mockable-android.jar</code> file.
</li>
<li>Fixed library project task dependencies so test classes recompile after changes.
</li>
</ul>
<li>Added the <code>testProguardFile</code> property to apply
<a href="{@docRoot}tools/help/proguard.html">ProGuard</a> files when minifying a test APK.
</li>
<li>Added the <code>timeOut</code> property to the <code>adbOptions</code> code block
for setting the maximum recording time for
<a href="{@docRoot}tools/help/adb.html">Android Debug Bridge</a> screen recording.
</li>
<li>Added support for 280 dpi resources.
</li>
<li>Improved performance during project evaluation.
</li>
</ul>
</dd>
</div>
</div>
<div class="toggle-content closed">
<p><a href="#" onclick="return toggleContent(this)">
<img src="{@docRoot}assets/images/triangle-closed.png" class="toggle-content-img"
alt=""/>Android Plugin for Gradle, Revision 1.1.3</a> <em>(March 2015)</em>
</p>
<div class="toggle-content-toggleme">
<dl>
<dt>Dependencies:</dt>
<dd>
<ul>
<li>Gradle 2.2.1 or higher.</li>
<li>Build Tools 21.1.1 or higher.</li>
</ul>
</dd>
<dt>General Notes:</dt>
<dd>
<ul>
<li>Fixed issue with duplicated dependencies on a test app that triggered a ProGuard failure. </li>
<li>Fixed Comparator implementation which did not comply with the JDK Comparator contract and
generated a JDK 7 error.</li>
</ul>
</dd>
</div>
</div>
<div class="toggle-content closed">
<p><a href="#" onclick="return toggleContent(this)">
<img src="{@docRoot}assets/images/triangle-closed.png" class="toggle-content-img"
alt=""/>Android Plugin for Gradle, Revision 1.1.2</a> <em>(February 2015)</em>
</p>
<div class="toggle-content-toggleme">
<dl>
<dt>Dependencies:</dt>
<dd>
<ul>
<li>Gradle 2.2.1 or higher.</li>
<li>Build Tools 21.1.1 or higher.</li>
</ul>
</dd>
<dt>General Notes:</dt>
<dd>
<ul>
<li>Normalized path when creating a mockable JAR for unit testing. </li>
<li>Fixed the <code>archivesBaseName</code> setting in the <code>build.gradle</code> file. </li>
<li>Fixed the unresolved placeholder failure in manifest merger when building a library
test application.</li>
</ul>
</dd>
</div>
</div>
<div class="toggle-content closed">
<p><a href="#" onclick="return toggleContent(this)">
<img src="{@docRoot}assets/images/triangle-closed.png" class="toggle-content-img"
alt=""/>Android Plugin for Gradle, Revision 1.1.1</a> <em>(February 2015)</em>
</p>
<div class="toggle-content-toggleme">
<dl>
<dt>Dependencies:</dt>
<dd>
<ul>
<li>Gradle 2.2.1 or higher.</li>
<li>Build Tools 21.1.1 or higher.</li>
</ul>
</dd>
<dt>General Notes:</dt>
<dd>
<ul>
<li>Modified build variants so only variants that package a
<a href="{@docRoot}training/wearables/apps/index.html">Wear</a> app trigger Wear-specific
build tasks. </li>
<li>Changed dependency related issues to fail at build time rather than at debug time.
This behavior allows you to run diagnostic diagnostic tasks (such as 'dependencies') to help
resolve the conflict. </li>
<li>Fixed the <code>android.getBootClasspath()</code> method to return a value. </li>
</ul>
</dd>
</div>
</div>
<div class="toggle-content closed">
<p><a href="#" onclick="return toggleContent(this)">
<img src="{@docRoot}assets/images/triangle-closed.png" class="toggle-content-img"
alt=""/>Android Plugin for Gradle, Revision 1.1.0</a> <em>(February 2015)</em>
</p>
<div class="toggle-content-toggleme">
<dl>
<dt>Dependencies:</dt>
<dd>
<ul>
<li>Gradle 2.2.1 or higher.</li>
<li>Build Tools 21.1.1 or higher.</li>
</ul>
</dd>
<dt>General Notes:</dt>
<dd>
<ul>
<li>Added new unit test support</li>
<ul>
<li>Enabled
<a href="{@docRoot}training/activity-testing/activity-unit-testing.html">unit tests</a> to
run on the local JVM against a special version of the <code>android.jar</code> file that is
compatible with popular mocking frameworks, for example Mockito. </li>
<li>Added new test tasks <code>testDebug</code>, <code>testRelease</code>, and
<code>testMyFlavorDebug</code> when using product flavors. </li>
<li>Added new source folders recognized as unit tests: <code>src/test/java/</code>,
<code>src/testDebug/java/</code>, <code>src/testMyFlavor/java/</code>.
<li>Added new configurations in the <code>build.gradle</code> file for declaring test-only
dependencies, for example, <code>testCompile 'junit:junit:4.11'</code>,
<code>testMyFlavorCompile 'some:library:1.0'</code>.
<p class="note"><strong>Note:</strong> Test-only dependencies are not currently compatible
with Jack (Java Android Compiler Kit). </p>
</li>
<li>Added the <code>android.testOptions.unitTests.returnDefaultValues</code> option to
control the behaviour of the mockable android.jar. </li>
</ul>
<li>Replaced <code>Test</code> in test task names with <code>AndroidTest</code>.
For example, the <code>assembleDebugTest</code> task is now
<code>assembleDebugAndroidTest</code> task. Unit test tasks still have <code>UnitTest</code>
in the task name, for example <code>assembleDebugUnitTest</code>. </li>
<li>Modified <a href="{@docRoot}tools/help/proguard.html">ProGuard</a> configuration files to
no longer apply to the test APK. If minification is enabled, ProGuard processes the test APK
and applies only the mapping file that is generated when minifying the main APK. </li>
<li>Updated dependency management</li>
<ul>
<li>Fixed issues using <code>provided</code> and <code>package</code> scopes.
<p class="note"><strong>Note:</strong> These scopes are incompatible with AAR
(Android ARchive) packages and will cause a build with AAR packages to fail.</p>
</li>
<li>Modified dependency resolution to compare the dependencies of an app under test and the
test app. If an artifact with the same version is found for both apps, it's not included with
the test app and is packaged only with the app under test. If an artifact with a different
version is found for both apps, the build fails.</li>
</ul>
<li>Added support for <code>anyDpi</code>
<a href="{@docRoot}guide/topics/resources/providing-resources.html"> resource qualifier</a>
in resource merger. </li>
<li>Improved evaluation and IDE sync speeds for projects with a large number of
Android <a href="{@docRoot}sdk/installing/create-project.html#CreatingAModule"> modules</a>. </li>
</ul>
</dd>
</div>
</div>
<div class="toggle-content closed">
<p><a href="#" onclick="return toggleContent(this)">
<img src="{@docRoot}assets/images/triangle-closed.png" class="toggle-content-img"
alt=""/>Android Plugin for Gradle, Revision 1.0.1</a> <em>(January 2015)</em>
</p>
<div class="toggle-content-toggleme">
<dl>
<dt>Dependencies:</dt>
<dd>
<ul>
<li>Gradle 2.2.1 up to 2.3.x.
<p class="note"><strong>Note:</strong> This version of the Android Plugin for Gradle is
not compatible with Gradle 2.4 and higher. </p>
</li>
<li>Build Tools 21.1.1 or higher.</li>
</ul>
</dd>
<dt>General Notes:</dt>
<dd>
<ul>
<li>Fixed issue with Gradle build failure when accessing the
<code>extractReleaseAnnotations</code> module.
(<a href="http://b.android.com/81638">Issue 81638</a>).</li>
<li>Fixed issue with <code>Disable</code> passing the
<code>--no-optimize</code> setting to the Dalvik Executable (dex) bytecode.
(<a href="http://b.android.com/82662">Issue 82662</a>).</li>
<li>Fixed manifest merger issues when importing libraries with a
<code>targetSdkVersion</code> less than 16.</li>
<li>Fixed density ordering issue when using Android Studio with JDK 8.</li>
</ul>
</dd>
</div>
</div>
<div class="toggle-content closed">
<p><a href="#" onclick="return toggleContent(this)">
<img src="{@docRoot}assets/images/triangle-closed.png" class="toggle-content-img"
alt=""/>Android Plugin for Gradle, Revision 1.0.0</a> <em>(December 2014)</em>
</p>
<div class="toggle-content-toggleme">
<dl>
<dt>Dependencies:</dt>
<dd>
<ul>
<li>Gradle 2.2.1 up to 2.3.x.
<p class="note"><strong>Note:</strong> This version of the Android Plugin for Gradle is
not compatible with Gradle 2.4 and higher. </p>
</li>
<li>Build Tools 21.1.1 or higher.</li>
</ul>
</dd>
<dt>General Notes:</dt>
<dd>
<ul>
<li>Initial plugin release.</li>
</ul>
</dd>
</div>
</div>
<h2>Updating the Android Plugin for Gradle Version</h2>
<p>The Android Plugin for Gradle version is specified in the
<strong>File &gt; Project Structure &gt; Project</strong> menu and the project-level
<code>build.gradle</code> file. The plugin version applies to all modules built in that
Android Studio project. This example sets the Android Plugin for Gradle to version 1.1.0 from the <code>build.gradle</code> file:
<pre>
...
dependencies {
classpath 'com.android.tools.build:gradle:1.1.0'
}
...
</pre>
<p class="caution"><strong>Caution:</strong> You should not use dynamic dependencies (+) in
version numbers. Using this feature can cause unexpected version updates and difficulty
resolving version differences. </p>
<p>If you're building with Gradle but not using Android Studio, the build process downloads the
latest Android Plugin for Gradle when it runs. </p>
<h2>Updating the Gradle Version </h2>
<p>Android Studio requires Gradle version 2.2.1 or later. To view and
update the Gradle version, edit the Gradle distribution reference in the
<code>gradle/wrapper/gradle-wrapper.properties</code> file. This example sets the
Gradle version to 2.2.1.</p>
<pre>
...
distributionUrl=http\://services.gradle.org/distributions/gradle-2.2.1-all.zip
...
</pre>
<p>For more details about the supported Android Plugin for Gradle properties and syntax, click
the link to the
<a href="{@docRoot}tools/building/plugin-for-gradle.html">Plugin Language Reference</a>.</p>