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

spencer

03/02/2020, 4:20 PM
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

wasyl

03/02/2020, 4:31 PM
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

spencer

03/02/2020, 5:24 PM
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

miqbaldc

03/02/2020, 10:13 PM
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

spencer

03/02/2020, 10:23 PM
I’m using view binding, not data binding.
m

miqbaldc

03/02/2020, 10:32 PM
does both your modules already include
viewBinding { isEnabled = true }
?
s

spencer

03/02/2020, 10:46 PM
Yes
m

Mark

03/03/2020, 2:59 AM
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

spencer

03/03/2020, 4:17 PM
This was resolved by updating my build tools version to 3.6.1
191 Views