https://kotlinlang.org logo
#android
Title
# android
p

petermonteer

11/25/2019, 1:19 PM
I'm moving away from using KotterKnife in my apps, since support and development was withdrawn a while ago. With ViewBinding still in Canary, what alternatives are you using, what are your recommendations?
j

jw

11/25/2019, 1:28 PM
It's in beta with RC around the corner
s

sindrenm

11/25/2019, 1:29 PM
As Jake mentioned, it's still in beta. Alternatives could be Kotlin synthetic imports, but we've been using view bindings for a while in production with no issues. 😎
p

petermonteer

11/25/2019, 1:31 PM
Yeah I've been using synthetics and it's been working fine, but it feels "unnatural" 😛 will be using it until view binding rc is released then, thanks guys! 👍
m

Matej Drobnič

11/25/2019, 2:07 PM
If you are just starting with the project then it will likely be in stable when you will be releasing, so using Viewbinding is fine.
p

Paul Woitaschek

11/25/2019, 2:47 PM
I found that ViewBinding (beta4) isn't ready yet; it fails to compile if you have includes in your layout from other gradle modules
Also you have to restart AS after every layout change because it's not picking up new layouts
🚫 1
😯 1
j

jw

11/25/2019, 2:50 PM
The former is already fixed. They branched 3.6 after the change and then i went on leave for two months.
Never heard or seen the latter. File a bug.
m

Matt Thompson

11/25/2019, 4:32 PM
you could start with the Data Binding library and not include variables in the xml, then the the main thing to change is the
<layout>
tag if/when you switch
💯 1
speaking of which, are there any plans to deprecate that library since the two are so similar? or just choose whichever works best for your needs?
p

petermonteer

11/25/2019, 4:37 PM
Taken from the official docs: Differences from the data binding library View binding and the data binding library both generate binding classes that you can use to reference views directly. However, there are notable differences: The data binding library processes only data binding layouts created using the <layout> tag. View binding doesn't support layout variables or layout expressions, so it can't be used to bind layouts with data in XML. https://developer.android.com/topic/libraries/view-binding
m

Matt Thompson

11/25/2019, 4:54 PM
yeah I was just saying hypothetically you could use data binding for only the autogenerated bindings and not mess with the xml expressions/binding adapters and get the same thing view binding gets you, not saying you should. guess that's why the view binding library exists. no idea how the autogen compares/if one is more performant than the other
p

petermonteer

11/25/2019, 4:55 PM
i think data binding is a little heavier, dont remember where i saw that
j

jw

11/25/2019, 4:56 PM
it's heavier
⚖️ 2
For a good comparison between the different options
And personal recommendations
p

Paul Woitaschek

12/17/2019, 7:38 PM
It's weird that it has entered RC 1 with vital stuff like this open: https://issuetracker.google.com/issues/142939794 Isn't RC mean to be "This might be finished and is a candidate for a release"?
s

sindrenm

12/18/2019, 12:31 PM
I saw they fixed a number of things regarding view/data binding. Have you tried the RC and verified that yours is still an issue? Thinking it could be related to https://issuetracker.google.com/issues/140882631, perhaps, which is fixed in this RC. Could of course be very wrong, as well. 😅
p

Paul Woitaschek

12/18/2019, 1:20 PM
Nope that's a different issue and the open issue is still reproducable on the rc1
3 Views