Is it possible to use Android DataBinding within a library project? I did create a library to be used for other people. Within this library I did use Android DataBinding. It did work on the same Android Studio project as a module, but when i install it to my local maven repo it wouldn't compile because of the generated files couldn't be found. As I checked the aar file, i couldn't find the generated databinding folder as well.
The following error will be produced:
error: cannot access HeaderToolBarBinding
class file for com.test.library.shared.databinding.HeaderToolBarBinding not found
Consult the following stack trace for details.
com.sun.tools.javac.code.Symbol$CompletionFailure: class file for
com.test.library.shared.databinding.HeaderToolBarBinding not found
1 error
Does anyone how we could solve this?
So,
- Shared project
---> App (include library by compile project(":shared")
---> Shared library (with DataBinding enabled)
- Project other people
---> App (include library by Gradle dependecies)
Yep, we don't use <layout> ViewBinding, because on DataBinding we must add that layout tag to generate Binding class and it's different with ViewBinding which automatically generates all layout to Binding class.
Using data binding can lead to faster development times, faster execution times and more readable and maintained code. Android data binding generates binding classes at compile time for layouts.
For DataBinding to work in an application using your library, both need to enable DataBinding in their build.gradle
file:
dataBinding {
enabled = true
}
Just update the gradle file of your app
dataBinding {
enabled=true
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With