Android Plugin for Gradle Release Notes
2016-12-22 15:15
309 查看
Skip to content
Android
Studio
FEATURES
USER GUIDE
navigation
User Guide
Meet Android Studio
Workflow Basics
Manage Your Project
Write Your App
Build and Run Your App
Configure Your Build
Debug Your App
Test Your App
Profile Your App
Publish Your App
Command Line Tools
Release Notes
SDK Tools
SDK Build Tools
Android Plugin for Gradle
SDK Platform
Troubleshoot
Back to Developers
DOWNLOAD
FEATURES
USER GUIDE
Update the Android Plugin for Gradle Version
Update the Gradle Version
Revisions
The Android Studio build system is based on Gradle, and the Android plugin for Gradle adds several features that are specific to building Android apps. Although the Android plugin is typically
updated in lock-step with Android Studio, the plugin (and the rest of the Gradle system) can run independent of Android Studio and be updated separately.
This page explains how to keep your Gradle tools up to date and what's in the recent
updates.
For details about how to configure your Android builds with Gradle, see the following pages:
Configure Your Build
Android Plugin DSL Reference
Gradle DSL Reference
For more information about the Gradle build system, see the Gradle
user guide.
based on your project's build requirements.
You can specify the Android plugin for Gradle version
in either the File > Project Structure > Project menu in Android Studio, or the top-level
The plugin version applies to all modules built in that Android Studio project. The following example sets the Android plugin for Gradle to version 2.2.0 from the
Caution: You should not use dynamic dependencies in version numbers, such as
Using this feature can cause unexpected version updates and difficulty resolving version differences.
If the specified plugin version has not been downloaded, Gradle downloads it the next time you build your project or click Tools > Android > Sync
Project with Gradle Files from the Android Studio menu bar.
requirements.
The following table lists which version of Gradle is required for each version of the Android plugin for Gradle. For the best performance, you should use the latest possible version of both Gradle and the
Android plugin.
You can specify the Gradle version in either the File > Project Structure > Project menu
in Android Studio, or by editing the Gradle distribution reference in the
The following example sets the Gradle version to 2.14.1 in the
Site.
Android
plugin for Gradle, revision 2.2.0 (September 2016)
Dependencies:
Gradle 2.14.1 or higher.
Build Tools 23.0.2 or higher.
New:
Uses Gradle 2.14.1, which includes performance improvements and new features, and fixes a security vulnerability that allows local privilege escalation when using the Gradle daemon. For more details, see the Gradle
release notes.
Using the
C and C++ Code to Your Project.
When you run a build from the command line, Gradle now attempts to auto-download
any missing SDK components or updates that your project depends on. To learn more, read Auto-download
missing packages with Gradle.
A new experimental caching feature lets Gradle speed up build times by pre-dexing, storing, and reusing the pre-dexed versions of your libraries. To learn more about using this experimental feature, read the Build
Cache guide.
Improves build performance by adopting a new default packaging pipeline which handles zipping, signing, and zipaligning in
one task. You can revert to using the older packaging tools by adding
your
is not available. However, you can create one yourself by calling the
APK signing now uses APK Signature Scheme v2 in addition
to traditional JAR signing. All Android platforms accept the resulting APKs. Any modification to these APKs after signing invalidates their v2 signatures and prevents installation on a device. To disable this feature, add the following to your module-level
For multidex builds, you can now use ProGuard rules to determine which classes Gradle should compile into your app’s main DEX file. Because the Android system loads the main DEX
file first when starting your app, you can prioritize certain classes at startup by compiling them into the main DEX file. After you create a ProGuard configuration file specifically for your main DEX file, pass the configuration file’s path to Gradle using
Using this DSL is different from using
which provides general ProGuard rules for your app and does not specify classes for the main DEX file.
Adds support for the
which can reduce the size of your app when you install it on a device. When you set this flag to
the
of your app manifest, Gradle packages uncompressed and aligned versions of your native libraries with your APK. This prevents
copying out your native libraries from the APK to the device's file system during installation and has the added benefit of making delta updates of your app smaller.
You can now specify
product flavors. (Issue 59614)
Changes:
files that Android plugin for Gradle provides and no longer uses the ones in the Android SDK.
Improved Jack compiler performance and features:
Jack now supports Jacoco test coverage when setting
Improved support for annotation processors. Annotation processors on your classpath, such as any
are automatically applied to your build. You can also specify an annotation processor in your build and pass arguments by using the
If you want to apply an annotation processor at compile time but not include it in your APK, use the
scope:
You can set additional flags for Jack using
The following code snippet sets the
For a list of parameters you can set, run the following from the command line:
By default, if the Gradle daemon's heap size is at least 1.5 GB, Jack now runs in the same process as Gradle. To adjust the daemon heap size, add the following to your
Android
plugin for Gradle, revision 2.1.3 (August 2016)
Android
plugin for Gradle, revision 2.1.0 (April 2016)
Android
plugin for Gradle, revision 2.0.0 (April 2016)
Android
plugin for Gradle, revision 1.5.0 (November 2015)
Android
plugin for Gradle, revision 1.3.1 (August 2015)
Android
plugin for Gradle, revision 1.3.0 (July 2015)
Android
plugin for Gradle, revision 1.2.0 (April 2015)
Android
plugin for Gradle, revision 1.1.3 (March 2015)
Android
plugin for Gradle, revision 1.1.2 (February 2015)
Android
plugin for Gradle, revision 1.1.1 (February 2015)
Android
plugin for Gradle, revision 1.1.0 (February 2015)
Android
plugin for Gradle, revision 1.0.1 (January 2015)
Android
plugin for Gradle, revision 1.0.0 (December 2014)
Get news & tips SIGN
UP FOR THE NEWSLETTER
Blog Support
ANDROID
DEVELOPERS ON YOUTUBE ANDROID
DEVELOPERS ON GOOGLE+ ANDROID
DEVELOPERS ON TWITTER
Except as noted, this content is licensed under Creative Commons Attribution 2.5.
For details and restrictions, see the Content License.
About Android Auto TV Wear Legal
Bahasa Indonesia
English
español
Português Brasileiro
Tiếng Việt
Русский
日本語
简体中文
繁體中文
한국어
Take a one-minute survey?
Help us improve Android tools and documentation.
Skip to content
Android
Studio
FEATURES
USER GUIDE
navigation
User Guide
Meet Android Studio
Workflow Basics
Manage Your Project
Write Your App
Build and Run Your App
Configure Your Build
Debug Your App
Test Your App
Profile Your App
Publish Your App
Command Line Tools
Release Notes
SDK Tools
SDK Build Tools
Android Plugin for Gradle
SDK Platform
Troubleshoot
Back to Developers
DOWNLOAD
FEATURES
USER GUIDE
Android Plugin for Gradle Release Notes
In this document
Update the Android Plugin for Gradle VersionUpdate the Gradle Version
Revisions
The Android Studio build system is based on Gradle, and the Android plugin for Gradle adds several features that are specific to building Android apps. Although the Android plugin is typically
updated in lock-step with Android Studio, the plugin (and the rest of the Gradle system) can run independent of Android Studio and be updated separately.
This page explains how to keep your Gradle tools up to date and what's in the recent
updates.
For details about how to configure your Android builds with Gradle, see the following pages:
Configure Your Build
Android Plugin DSL Reference
Gradle DSL Reference
For more information about the Gradle build system, see the Gradle
user guide.
Update the Android Plugin for Gradle
When you update Android Studio, you may receive a prompt to automatically update the Android plugin for Gradle to the latest available version. You can choose to accept the update or manually specify a versionbased on your project's build requirements.
You can specify the Android plugin for Gradle version
in either the File > Project Structure > Project menu in Android Studio, or the top-level
build.gradlefile.
The plugin version applies to all modules built in that Android Studio project. The following example sets the Android plugin for Gradle to version 2.2.0 from the
build.gradlefile:
buildscript { ... dependencies { classpath 'com.android.tools.build:gradle:2.2.0' } }
Caution: You should not use dynamic dependencies in version numbers, such as
'com.android.tools.build:gradle:2.+'.
Using this feature can cause unexpected version updates and difficulty resolving version differences.
If the specified plugin version has not been downloaded, Gradle downloads it the next time you build your project or click Tools > Android > Sync
Project with Gradle Files from the Android Studio menu bar.
Update Gradle
When you update Android Studio, you may receive a prompt to also update Gradle to the latest available version. You can choose to accept the update or manually specify a version based on your project's buildrequirements.
The following table lists which version of Gradle is required for each version of the Android plugin for Gradle. For the best performance, you should use the latest possible version of both Gradle and the
Android plugin.
Plugin version | Required Gradle version |
---|---|
1.0.0 - 1.1.3 | 2.2.1 - 2.3 |
1.2.0 - 1.3.1 | 2.2.1 - 2.9 |
1.5.0 | 2.2.1 - 2.13 |
2.0.0 - 2.1.2 | 2.10 - 2.13 |
2.1.3+ | 2.14.1+ |
in Android Studio, or by editing the Gradle distribution reference in the
gradle/wrapper/gradle-wrapper.propertiesfile.
The following example sets the Gradle version to 2.14.1 in the
gradle-wrapper.propertiesfile.
... distributionUrl = https\://services.gradle.org/distributions/gradle-2.14.1-all.zip ...
Revisions
For a summary of known issues in Android plugin for Gradle, visit the Android Tools ProjectSite.
Android
plugin for Gradle, revision 2.2.0 (September 2016)
Dependencies:
Gradle 2.14.1 or higher.
Build Tools 23.0.2 or higher.
New:
Uses Gradle 2.14.1, which includes performance improvements and new features, and fixes a security vulnerability that allows local privilege escalation when using the Gradle daemon. For more details, see the Gradle
release notes.
Using the
externalNativeBuild {}DSL, Gradle now lets you link to your native sources and compile native libraries using CMake or ndk-build. After building your native libraries, Gradle packages them into your APK. To learn more about using CMake and ndk-build with Gradle, read Add
C and C++ Code to Your Project.
When you run a build from the command line, Gradle now attempts to auto-download
any missing SDK components or updates that your project depends on. To learn more, read Auto-download
missing packages with Gradle.
A new experimental caching feature lets Gradle speed up build times by pre-dexing, storing, and reusing the pre-dexed versions of your libraries. To learn more about using this experimental feature, read the Build
Cache guide.
Improves build performance by adopting a new default packaging pipeline which handles zipping, signing, and zipaligning in
one task. You can revert to using the older packaging tools by adding
android.useOldPackaging=trueto
your
gradle.propertiesfile. While using the new packaging tool, the
zipalignDebugtask
is not available. However, you can create one yourself by calling the
createZipAlignTask(String taskName, File inputFile, File outputFile)method.
APK signing now uses APK Signature Scheme v2 in addition
to traditional JAR signing. All Android platforms accept the resulting APKs. Any modification to these APKs after signing invalidates their v2 signatures and prevents installation on a device. To disable this feature, add the following to your module-level
build.gradlefile:
android { ... signingConfigs { config { ... v2SigningEnabled false } } }
For multidex builds, you can now use ProGuard rules to determine which classes Gradle should compile into your app’s main DEX file. Because the Android system loads the main DEX
file first when starting your app, you can prioritize certain classes at startup by compiling them into the main DEX file. After you create a ProGuard configuration file specifically for your main DEX file, pass the configuration file’s path to Gradle using
buildTypes.multiDexKeepProguard.
Using this DSL is different from using
buildTypes.proguardFiles,
which provides general ProGuard rules for your app and does not specify classes for the main DEX file.
Adds support for the
android:extractNativeLibsflag,
which can reduce the size of your app when you install it on a device. When you set this flag to
falsein
the
<application>element
of your app manifest, Gradle packages uncompressed and aligned versions of your native libraries with your APK. This prevents
PackageManagerfrom
copying out your native libraries from the APK to the device's file system during installation and has the added benefit of making delta updates of your app smaller.
You can now specify
versionNameSuffixand
applicationIdSuffixfor
product flavors. (Issue 59614)
Changes:
getDefaultProguardFilenow returns the default ProGuard
files that Android plugin for Gradle provides and no longer uses the ones in the Android SDK.
Improved Jack compiler performance and features:
Jack now supports Jacoco test coverage when setting
testCoverageEnabledto
true.
Improved support for annotation processors. Annotation processors on your classpath, such as any
compiledependencies,
are automatically applied to your build. You can also specify an annotation processor in your build and pass arguments by using the
javaCompileOptions.annotationProcessorOptions {}DSL in your module-level
build.gradlefile:
android { ... defaultConfig { ... javaCompileOptions { annotationProcessorOptions { className 'com.example.MyProcessor' // Arguments are optional. arguments = [ foo : 'bar' ] } } } }
If you want to apply an annotation processor at compile time but not include it in your APK, use the
annotationProcessordependency
scope:
dependencies { compile 'com.google.dagger:dagger:2.0' annotationProcessor 'com.google.dagger:dagger-compiler:2.0' // or use buildVariantAnnotationProcessor to target a specific build variant }
You can set additional flags for Jack using
jackOptions.additionalParameters().
The following code snippet sets the
jack.incrementalparameter to
true:
android { defaultConfig { ... jackOptions { enabled true additionalParameters("jack.incremental" : true) } } ... }
For a list of parameters you can set, run the following from the command line:
java -jar /build-tools/jack.jar --help-properties
By default, if the Gradle daemon's heap size is at least 1.5 GB, Jack now runs in the same process as Gradle. To adjust the daemon heap size, add the following to your
gradle.propertiesfile:
# This sets the daemon heap size to 1.5GB. org.gradle.jvmargs=-Xmx1536M
Android
plugin for Gradle, revision 2.1.3 (August 2016)
Android
plugin for Gradle, revision 2.1.0 (April 2016)
Android
plugin for Gradle, revision 2.0.0 (April 2016)
Android
plugin for Gradle, revision 1.5.0 (November 2015)
Android
plugin for Gradle, revision 1.3.1 (August 2015)
Android
plugin for Gradle, revision 1.3.0 (July 2015)
Android
plugin for Gradle, revision 1.2.0 (April 2015)
Android
plugin for Gradle, revision 1.1.3 (March 2015)
Android
plugin for Gradle, revision 1.1.2 (February 2015)
Android
plugin for Gradle, revision 1.1.1 (February 2015)
Android
plugin for Gradle, revision 1.1.0 (February 2015)
Android
plugin for Gradle, revision 1.0.1 (January 2015)
Android
plugin for Gradle, revision 1.0.0 (December 2014)
Get news & tips SIGN
UP FOR THE NEWSLETTER
Blog Support
ANDROID
DEVELOPERS ON YOUTUBE ANDROID
DEVELOPERS ON GOOGLE+ ANDROID
DEVELOPERS ON TWITTER
Except as noted, this content is licensed under Creative Commons Attribution 2.5.
For details and restrictions, see the Content License.
About Android Auto TV Wear Legal
Bahasa Indonesia
English
español
Português Brasileiro
Tiếng Việt
Русский
日本語
简体中文
繁體中文
한국어
Take a one-minute survey?
Help us improve Android tools and documentation.
相关文章推荐
- Android Plugin for Gradle Release Notes
- Android Plugin for Gradle Release Notes
- Error:(171, 0) No such property: sdkHandler for class: com.android.build.gradle.LibraryPlugin
- Gradle Plugin for Android Development User Guide (2)
- Error:(117, 0) No such property: sdkHandler for class: com.android.build.gradle.AppPlugin的解决办法
- Migrate to Android Plugin for Gradle 3.0.0
- Android plugin for Gradle基础
- 彻底搞懂Gradle、Gradle Wrapper与Android Plugin for Gradle的区别和联系
- Android Plugin for Gradle 3.0.0踩坑记录
- Gradle for Android-创建task和plugin
- 问题Android Plugin for Gradle version 1.5.0 does not support Instant R
- Android Studio Gradle project refresh failed No such property classpath for class
- Gradle plugin for Eclipse
- android studio gradle plugin 用户指南 选择性翻译
- Android Gradle Plugin指南(六)——高级构建定制
- Plugin-X Integration Guide for Android
- Android Gradle Plugin指南(二)——基本项目
- Android Gradle Plugin指南(四)——测试
- Conflicting collector combinations in option list; please refer to the release notes for the combina
- [Android Tips] 11. How to Create a Release Signed APK File using Gradle