问题
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)
回答1:
For DataBinding to work in an application using your library, both need to enable DataBinding in their build.gradle
file:
dataBinding {
enabled = true
}
回答2:
Just update the gradle file of your app
dataBinding {
enabled=true
}
来源:https://stackoverflow.com/questions/38442332/how-to-use-android-databinding-within-a-library