Hi there,
I used synthetic binding in my project
It is everywhere like Activities, Fragments, RVAdapters
Now it is deprecated and I have no clue how to convert it to view binding
For now I only understand that I have to change it in every class manually
Is there any automatic solution or tool available?
@kenkyee nothing wrong in documentation and I am clear with it
https://developer.android.com/topic/libraries/view-binding
The question is that I used kotlin synthetic view binding and now it is deprecated so I am looking for automatic tool to convert this synthetic view binding to view binding
t
tseisel
12/20/2020, 9:59 AM
There should be a way to automate that process, but no tool is currently available.
If you intend to write one, you'd need to:
- Scan XML layout files in the same way as the ViewBinding tool, to find out view ids in all configurations
- Convert them to camelCase, and convert the layout file to PascalCase
- Replace
view_id
at call site by
binding.viewId
, accounting for nullable views (in Kotlin and Java)
- Create the viewbinding instance: that's the really hard point, as you could either inflate it or bind to an existing view hierarchy.
- Clear imports.