Android Plugin for Gradle Release Notes


Skip to content

navigation

Android Plugin for Gradle Release Notes

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:

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 version 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-levelbuild.gradle file. 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.gradle file:

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 build 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.

Plugin versionRequired Gradle version
1.0.0 - 1.1.32.2.1 - 2.3
1.2.0 - 1.3.12.2.1 - 2.9
1.5.02.2.1 - 2.13
2.0.0 - 2.1.22.10 - 2.13
2.1.3+2.14.1+

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 gradle/wrapper/gradle-wrapper.properties file. The following example sets the Gradle version to 2.14.1 in the gradle-wrapper.properties file.

...
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 Project Site.

Android plugin for Gradle, revision 2.2.0 (September 2016)

Dependencies:
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=true to your gradle.properties file. While using the new packaging tool, the zipalignDebug task is not available. However, you can create one yourself by calling thecreateZipAlignTask(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.gradle file:
    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 usingbuildTypes.proguardFiles, which provides general ProGuard rules for your app and does not specify classes for the main DEX file.
  • Adds support for the android:extractNativeLibs flag, which can reduce the size of your app when you install it on a device. When you set this flag to false in the <application> element of your app manifest, Gradle packages uncompressed and aligned versions of your native libraries with your APK. This prevents PackageManager from 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 versionNameSuffix and applicationIdSuffix for product flavors. (Issue 59614)
Changes:
  • getDefaultProguardFile now 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 testCoverageEnabled to true.
    • Improved support for annotation processors. Annotation processors on your classpath, such as any compile dependencies, are automatically applied to your build. You can also specify an annotation processor in your build and pass arguments by using thejavaCompileOptions.annotationProcessorOptions {} DSL in your module-level build.gradle file:
      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 annotationProcessor dependency 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 thejack.incremental parameter 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.properties file:
      # 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)


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

  1.                       
  2.              Bahasa Indonesia                                 
  3.              English                                 
  4.              español                                 
  5.              Português Brasileiro                                 
  6.              Tiếng Việt                                 
  7.              Русский                                 
  8.              日本語                                 
  9.              简体中文                                 
  10.              繁體中文                                 
  11.              한국어                               
Take a one-minute survey?
Help us improve Android tools and documentation.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值