Android Gradle Plugin 3.2.0 (сентябрь 2018 г.)

Для работы этой версии плагина для Android требуются следующие компоненты:

Минимальная версия Версия по умолчанию Примечания
Грэдл 4.6 4.6 Для получения более подробной информации см. раздел «Обновление Gradle» .
Инструменты сборки SDK 28.0.3 28.0.3 Установите или настройте инструменты сборки SDK.

3.2.1 (октябрь 2018 г.)

Благодаря этому обновлению вам больше не нужно указывать версию для инструментов сборки SDK. Теперь плагин Android Gradle по умолчанию использует версию 28.0.3.

Новые функции

  • Support for building Android App Bundles: The app bundle is a new upload format that includes all your app's compiled code and resources while deferring APK generation and signing to the Google Play Store. You no longer have to build, sign, and manage multiple APKs, and users get smaller downloads that are optimized for their device. To learn more, read About Android App Bundles .

  • Поддержка повышения скорости инкрементальной сборки при использовании обработчиков аннотаций: DSL AnnotationProcessorOptions теперь расширяет CommandLineArgumentProvider , что позволяет вам или автору обработчика аннотаций аннотировать аргументы для обработчика с помощью аннотаций типов свойств инкрементальной сборки . Использование этих аннотаций повышает корректность и производительность инкрементальных и кэшированных чистых сборок. Чтобы узнать больше, прочитайте раздел «Передача аргументов обработчикам аннотаций» .

  • Migration tool for AndroidX: When using Android Gradle plugin 3.2.0 with Android 3.2 and higher, you can migrate your project's local and Maven dependencies to use the new AndroidX libraries by selecting Refactor > Migrate to AndroidX from the menu bar. Using this migration tool also sets the following flags to true in your gradle.properties file:

    • android.useAndroidX : When set to true , the Android plugin uses the appropriate AndroidX library instead of a Support Library. When this flag is not specified, the plugin sets it to false by default.

    • android.enableJetifier : When set to true , the Android plugin automatically migrates existing third-party libraries to use AndroidX by rewriting their binaries. When this flag is not specified, the plugin sets it to false by default. You can set this flag to true only while android.useAndroidX is also set to true , otherwise you get a build error.

      Чтобы узнать больше, ознакомьтесь с обзором AndroidX .

  • New code shrinker, R8: R8 is a new tool for code shrinking and obfuscation that replaces ProGuard. You can start using the preview version of R8 by including the following in your project's gradle.properties file:

            android.enableR8 = true
            
            android.enableR8 = true
            

Изменения в поведении

  • Функция обессахаривания с помощью D8 теперь включена по умолчанию.

  • AAPT2 теперь доступен в репозитории Maven от Google. Чтобы использовать AAPT2, убедитесь, что в вашем файле build.gradle присутствует зависимость google() , как показано ниже:

              buildscript {
                    repositories {
                        google() // here
                        jcenter()
                    }
                    dependencies {
                        classpath 'com.android.tools.build:gradle:3.2.0'
                    }
                }
                allprojects {
                    repositories {
                        google() // and here
                        jcenter()
                }
              
              buildscript {
                    repositories {
                        google() // here
                        jcenter()
                    }
                    dependencies {
                        classpath 'com.android.tools.build:gradle:3.2.0'
                    }
                }
                allprojects {
                    repositories {
                        google() // and here
                        jcenter()
                }
              
  • Native multidex is now enabled by default. Previous versions of Android Studio enabled native multidex when deploying the debug version of an app to a device running Android API level 21 or higher. Now, whether you're deploying to a device or building an APK for release, the Android Gradle plugin enables native multidex for all modules that set minSdkVersion=21 or higher.

  • Теперь плагин требует установки минимальной версии плагина protobuf (0.8.6), плагина Kotlin (1.2.50) и плагина Crashlytics (1.25.4).

  • The feature module plugin, com.android.feature , now enforces the use of only letters, digits, and underscores when specifying a module name. For example, if your feature module name includes dashes, you get a build error. This behavior matches that of the dynamic feature plugin.

Исправлены ошибки

  • Теперь JavaCompile поддерживает кэширование в проектах с привязкой данных. ( Проблема #69243050 )
  • Улучшена процедура предотвращения ошибок компиляции для библиотечных модулей с привязкой данных. ( Проблема #77539932 )
  • Теперь вы можете повторно включить настройку по запросу, если отключали её в более ранних версиях из-за некоторых непредсказуемых ошибок сборки. ( Проблема #77910727 )