Posted by Murat Yener, Developer Advocate

Today notes the launch of the initial Canary variation of Android Studio Arctic Fox (2020.3.1), along with Android Gradle plugin (AGP) variation 7.0.0-alpha01. With this launch we are changing the variation numbering for our Gradle plugin as well as decoupling it from the Android Studio versioning system. In this post we’ll describe the factors for the modification, along with provide a sneak peek of some vital adjustments we’re making to our brand-new, breeding Android Gradle plugin APIs as well as DSL.

New versioning system

With AGP 7.0.0 we are taking on the concepts of semantic versioning. What this indicates is that just significant variation adjustments will certainly damage API compatibility. We plan to launch one significant variation yearly, right after Gradle presents its very own annual significant launch.

Moreover, when it comes to a breaking modification, we will certainly guarantee that the eliminated API is noted with @Deprecated regarding a year beforehand which its substitute is readily available at the very same time. This will certainly provide designers about a year to move as well as evaluate their plugins with the brand-new API prior to the old API is eliminated.

Alignment with Gradle’s variation is likewise why we’re missing variations 5 as well as 6, as well as relocating straight to AGP 7.0.0. This positioning suggests that AGP 7.x is implied to collaborate with Gradle 7.x APIs. While it might likewise operate on Gradle 8.x, this is not ensured as well as will certainly rely on whether 8.x gets rid of APIs that AGP relies upon.

With this modification, the AGP variation number will certainly be decoupled from the Android Studio variation number. However we will certainly maintain launching Android Studio as well as Android Gradle plugin with each other for the direct future.

Compatibility in between Android Studio as well as Android Gradle plugin stays unmodified. As a basic policy, jobs that utilize steady variations of AGP can be opened up with more recent variations of Android Studio.

Java 11 demand

You can still utilize Java shows language variation 8 with AGP 7.0.0-alpha01 yet we are altering the minimum needed Java shows language variation to Java 11, beginning with AGP 7.0.0-alpha02. We are revealing this very early in the Canary routine as well as lots of months in advance of the steady launch to enable designers time to prepare yourself.

Incubating APIs as well as vital API adjustments

This launch of AGP likewise presents some API adjustments. As a pointer, a variety of APIs that were presented in AGP 4.1 were noted as incubating as well as went through transform. In truth, in AGP 4.2 several of these APIs have actually transformed. The APIs that are presently breeding do not comply with the deprecation cycle that we describe above.

Here is a recap of some vital API adjustments.

  • The onVariants, onProperties as well as onVariantFeatures blocks are eliminated in variation 4.2 beta.
  • These APIs are changed with prior toVariants as well as onVariants in the brand-new androidComponents block. Both prior toVariants as well as onVariants can additionally utilize a VariantSelector to lower the variety of versions the callback will certainly operate on, based upon develop kind, name or taste by utilizing withBuildType, withName as well as withFlavor appropriately. The lambda onVariants as well as prior toVariants obtains is performed after AGP calculates alternative mixes in afterEvaluate. Nesting residential or commercial properties inside onVariants is eliminated.
  • Similar APIs are contributed to androidComponents to enable different blocks for UnitTests (beforeUnitTest as well as unitTest) as well as AndroidExaminations (prior toAndroidExamination as well as androidTest) rather than nesting examinations inside versions.
  • Two courses made use of by both the old as well as brand-new means of signing up activities for versions were relabelled. Variant is currently VariantContractor, as well as it is made use of in the prior toVariants stage. VariantFeatures is currently Variant as well as it is passed to the brand-new onVariants block.

Let’s have a look at several of these adjustments. Here is an example onVariants block which targets the launch develop. The onVariants block Is transformed to prior toVariants as well as makes use of an alternative selector in the copying.

```
android {
   …
   //onVariants.withName("release") {
   //   ...
   //}
   …
}
androidComponents {
   val launch = selector().withBuildType("release")
   prior toVariants(launch) { alternative ->
      ...
   }
}

```

Similarly onVariantFeatures block is transformed to onVariants.

```
android {
   ...
   //onVariantFeatures {
   //   ... 
   //}
   …
}

androidComponents.onVariants { alternative ->
      ... 
}

```

Note, this modification is normally performed in a plugin as well as ought to not be found in build.gradle. We are relocating far from making use of features with receivers which fit the DSL phrase structure yet are not required in the plugin code.

We are intending to make these APIs steady with AGP 7.0.0 as well as all plugin writers have to move to the brand-new androidComponents. If you wish to prevent taking care of such adjustments, ensure your plugins just utilize steady APIs as well as do not rely on APIs noted as incubating.

If you wish to find out more regarding various other adjustments featuring this launch, ensure to have a look at the launch notes.

Java is a signed up hallmark of Oracle and/or its associates.