Discontinuing Kotlin synthetics for views

0
13


Posted by Márton Braun, Developer Relations Engineer

ALT TEXT GOES HERE 

Artificial properties to entry views have been created as a approach to get rid of the widespread boilerplate of findViewById calls. These synthetics are supplied 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 advisable eradicating the plugin out of your initiatives. We all know many builders nonetheless depend upon this plugin’s options, and we’ve prolonged the assist timeframe so you have got extra time to finish your migrations.

We at the moment are setting a deadline for these migrations: the plugin will probably be eliminated in Kotlin 1.8, which is predicted to be launched by the finish of 2022. At the moment, you received’t be capable to replace your mission to newer Kotlin variations if it nonetheless is determined by the Kotlin Android Extensions plugin. Because of this now’s the time to carry out the required migrations in your initiatives.

As an alternative of synthetics, we suggest utilizing View Binding, which generates type-safe binding courses from XML structure information. These bindings present handy entry to view references they usually work safely for layouts with a number of configurations. See the migration information for detailed directions on tips on how to undertake View Binding. Should you encounter any points, you may report a bug on the Challenge 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 function included within the plugin is Parcelize, which helps you create parcelable courses. Parcelize is now accessible 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.

Should you’re nonetheless utilizing the Kotlin Android Extensions Gradle plugin, kick off your migration in time as a way to preserve upgrading to new Kotlin releases sooner or later. This may allow you to make use of the newest language options and make the most of tooling and compiler enhancements.



LEAVE A REPLY

Please enter your comment!
Please enter your name here