Posted by Márton Braun, Developer Relations Engineer
Artificial properties to entry views have been created as a option to get rid of the frequent boilerplate of
findViewById calls. These synthetics are offered by JetBrains within the Kotlin Android Extensions Gradle plugin (to not be confused with Android KTX).
In November 2020, we introduced that this plugin has been deprecated in favor of higher options, and we beneficial eradicating the plugin out of your initiatives. We all know many builders nonetheless rely upon this plugin’s options, and we’ve prolonged the help timeframe so you’ve gotten extra time to finish your migrations.
We at the moment are setting a deadline for these migrations: the plugin will likely be eliminated in Kotlin 1.8, which is anticipated to be launched by the finish of 2022. At the moment, you gained’t be capable of replace your undertaking to newer Kotlin variations if it nonetheless relies on the Kotlin Android Extensions plugin. Because of this now could be the time to carry out the mandatory migrations in your initiatives.
As an alternative of synthetics, we advocate utilizing View Binding, which generates type-safe binding lessons from XML structure information. These bindings present handy entry to view references and so they work safely for layouts with a number of configurations. See the migration information for detailed directions on the best way to undertake View Binding. If you happen to encounter any points, you may report a bug on the Problem Tracker.
When constructing new options, think about using Jetpack Compose, Android’s trendy UI toolkit. Layouts constructed with Compose are declarative Kotlin code, eliminating the necessity to work with view references.
One other characteristic included within the plugin is Parcelize, which helps you create parcelable lessons. Parcelize is now obtainable within the standalone
kotlin-parcelize plugin with unchanged performance. To stand up and working with the brand new plugin, try the Parcelize documentation web page.
If you happen to’re nonetheless utilizing the Kotlin Android Extensions Gradle plugin, kick off your migration in time so to maintain upgrading to new Kotlin releases sooner or later. This can allow you to make use of the newest language options and make the most of tooling and compiler enhancements.