18.6 Choosing an Option
The introduction of view binding does not invalidate the previous options and both will continue to be widely supported for the foreseeable future. In terms of avoiding null pointer exceptions, however, view bindings are clearly the safer option when compared to using the findViewById() method. When developing your own projects, therefore, view binding should probably be used.
With regards to the examples in this book, however, it is important to keep in mind that view bindings are not enabled by default in Android Studio 4.1. Unfortunately, to use view bindings in the book examples it would be necessary to manually repeat each of the build.gradle and onCreate() method changes in this chapter over 50 times. For this reason alone, the examples in this book continue to use synthetic properties.
That being said, there is no reason why you should not follow the steps in this chapter to adapt the examples in this book to use view bindings if you wish to do...