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

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…

Similar Posts

34 thoughts on “Kotlin Synthetic (Deprecated) – Migrate to View Binding | Android Studio Tutorial
  1. Hello. I have done exactly what you did but I encountered a problem when I migrate the Main Activity into View Binding. It did not generate ActivityMainBinding. What do you think is the reason? Thank you.

  2. Hello, great video as always. ViewBinding amazing and working fine with Fragments, yet I had a hard time to use it when I walked with several activities that not part of the navigation, inactivity fine, but when I just to the next activity I personally had a hard time to initialize and even after it seems like all smooth and well it return null. in most cases. Is there a way to use viewBinding in a project with several activities? Another question might be i should not even bother with it? because fragments seem to be the future. Yet when I only need 2-3 pages it feels faster and easy to just use Inten instead of nav_… yea forgot view binding is auto-generated so it sure quicker 🙂

  3. Hi, just transitioning from java, and… what is the java equivalent of val binding get() = _binding!! and also what is that !! at the end? 🙂

  4. How to use with custom alert dialogs and bottom sheet dialogs?
    I have 4 different layout files for dialogs and bottom sheets
    How to convert them into ViewBinding with activity and fragments?

  5. If you want a layout file to be ignored while generating binding classes, add the tools:viewBindingIgnore="true" attribute to the root view of that layout file.

Leave a Reply

Your email address will not be published. Required fields are marked *