如何在库中使用android数据绑定 [英] How to use android databinding within a library
问题描述
是否可以在库项目中使用Android DataBinding?我确实创建了一个供其他人使用的库.在该库中,我确实使用了Android DataBinding.它确实可以在与模块相同的Android Studio项目上工作,但是当我将其安装到本地Maven存储库时,由于找不到生成的文件,它将无法编译. 当我检查aar文件时,我也找不到生成的数据绑定文件夹.
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.
将产生以下错误:
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?
所以
- Shared project
---> App (include library by compile project(":shared")
---> Shared library (with DataBinding enabled)
- Project other people
---> App (include library by Gradle dependecies)
推荐答案
要使DataBinding在使用您的库的应用程序中工作,两者都需要在其build.gradle
文件中启用DataBinding:
For DataBinding to work in an application using your library, both need to enable DataBinding in their build.gradle
file:
dataBinding {
enabled = true
}
这篇关于如何在库中使用android数据绑定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!