-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
runtime module和插件module中都使用了Databinding, 会产生冲突 #5
Comments
这是插件中应该使用的databinding自动生成的类, 会初始化插件module中所有的Mapper并添加到列表里,但是实际会调用runtime的该类并初始化runtime的Mapper; package androidx.databinding; public class DataBinderMapperImpl extends MergedDataBinderMapper { |
可以在插件中以 compileOnly 的方式引入冲突的库. 或者等等我针对这个场景在demo中加一个最佳实践的例子. |
Databinding的引入方式比较特殊(gradle文件配置android.buildFeatures.dataBinding = true), 冲突的类也很特殊, build时动态生成的同一个类(androidx.databinding.DataBinderMapperImpl ), 但是里面的内容并不相同, 内容如上面的代码,初始化了插件module自己的另一个DataBinderMapperImpl. |
好的, 谢谢反馈, 我看看怎么解决 |
麻烦大佬了. 除了这个特殊情况, xplugin框架真的强大且易用. |
这个问题有解决吗? |
我项目里的插件没有用DataBinding了, 因为DataBinding的初始化和XPlugin的实现原理冲突太大, 很难适配, 直接放弃好一点. 如果只是绑定布局, 可以替换为ViewBinding, ViewBinding没有全局初始化, 不会冲突. |
插件第一次调用DataBindingUtil.setContentView()时, 会初始化androidx.databinding.DataBinderMapperImpl对象,
但是runtime module中也有同样的类,于是就初始化了错误的类(不同的包名的DataBinderMapperImpl类),引发错误.
类似这种冲突有什么解决方案吗
The text was updated successfully, but these errors were encountered: