Reputation: 4312
Supposedly I have two android modules
ModuleA
- HelloWorld.Xml
ModuleB
- HelloWorld.Xml
Notice I have same xml layouts in different modules.
Now there will be two item bindings generated that would also be properly kept in their corresponding module
ModuleA
- HelloWorld.Xml
- HelloWorldItemBinding.java
ModuleB
- HelloWorld.Xml
- HelloWorldItemBinding.java
This compiles however when we land on ModuleB's HelloWorld.xml we get an error with the following
Cannot cast ModuleA.HelloWorldItemBinding to ModuleB.HelloWorldItemBinding.
I understand that this is because the project's modules are actually merged at compile time , however I still dont understand that when two binding files are actually created already at build time , why does android have an issue with finding the right one ?.
Also I couldn't find any link on this subject about databindings in multiple modules caveats at the official documentation
Upvotes: 3
Views: 1082
Reputation: 6834
By default, a binding class is generated based on the name of the layout file but you can set custom binding class name or full package name to avoid conflict.
ModuleA
<data class="HelloWorldModuleA">
…
</data>
ModuleB
<data class="HelloWorldModuleB">
…
</data>
here is official info
Upvotes: 3