Is there a trick to using View Binding with multip...
# android
s
Is there a trick to using View Binding with multiple modules? The bindings aren’t being generated when I add it to a second module.
w
With DataBinding you need to enable it in Gradle for both library modules and the app module as well
Even if app module doesn’t contain views or bindings itself
s
It’s still not working for me after I enabling it in the app module. I get
Copy code
error: package mypackage.databinding does not exist
import mypackage.databinding.MyLayoutBinding
m
do you have a custom binding adapter? or using
<data>
tag also using it in your xml like this:
Copy code
<TextView
  app:customBinding="@{variable1}" />
you might want to check if the
customBinding
match with your data type sometimes data binding won’t generated any layout if there’s an error of it 1. wrong syntax 2. wrong data type provided 3. unescaped strings 4.
Integer
data type but using it in
CharSequence
attributes, e.g:
android:text="@{thisIntegerValue}
won’t works
s
I’m using view binding, not data binding.
m
does both your modules already include
viewBinding { isEnabled = true }
?
s
Yes
m
Same as this? https://issuetracker.google.com/issues/140955511 It’s working for my multi-module application. Also have a look at this: https://issuetracker.google.com/issues/149045351
s
This was resolved by updating my build tools version to 3.6.1
207 Views