Kotlin Synthetic (Deprecated) - Migrate to View Binding | Android Studio Tutorial

Published: 04 December 2020
on channel: Stevdza-San
24,064
661

🏆 My Online Courses
⭐Discount Coupon: LAUNCH-STEVDZA-SAN
https://stevdza-san.com

🐱‍👤 Wanna become a member? Join!
   / @stevdzasan  

📸 Instagram
  / stevdza_san  


In Kotlin 1.4.20-M2 JetBrains deprecated Kotlin Android Extensions compiler plugin. That plugin contains:

Synthetics - let you replace calls to findViewById with kotlinx.android.synthetic bindings.
Parcelize allows you to remove boilerplate and easily create Parcelables through the @Parcelize annotation.

Best alternative for Kotlin Synthetic is View Binding. View Binding is the recommendation for view lookup as well as binding, but it does add a bit of overhead when compared to Android Kotlin Extensions.
Compared to Kotlin Extensions, it adds compile time checking of view lookups and type safety.

In this video I'm going to show you how to easily migrate to View Binding and use it in your Activities and Fragments.


Timestamps:
0:00 - Introduction
1:42 - How it was before
3:46 - Migrate to View Binding - Fragments
5:57 - Migrate to View Binding - Activities