Reputation: 5459
I have a multi-module project where I set my databinding classes as a generic type requirement:
public abstract class BaseActivity<DataBinding extends ViewDataBinding> {
//Rest of the code...
}
However, if I extend this activity on a submodule, sometimes I get the following build error:
error: cannot find symbol public void myMethod(MyActivityBinding dataBinding) {
error: package com.mydomain.databinding does not exist import com.mydomain.databinding.MyActivityBinding;
Sometimes, creating another activity that extends from MyActivity
and putting it on the main app module fixes the issue. But in some cases I can't pinpoint the problem, and I consistently get the same error message.
I already tried cleaning and rebuilding the project and also invalidating Android Studio cache and restarting it without success.
Any ideas on how to at least investigate what could be causing this problem?
Upvotes: 1
Views: 454
Reputation: 334
Not sure about the root cause of the problem but I have similar issue and posted answer here https://stackoverflow.com/a/47718646/3160214
In few words, this is how solution looks like:
class A<BINDING extends ViewDataBinding> extends BaseActivity<BINDING> {
protected ABinding binding;
void init(){
binding = (ABinding) DataBindingUtil.setContentView(this, R.layout.a);
}
}
and pass the same binding to the child class from the submodule
class B<ABinding> {
// you can use instance in this class
}
Upvotes: 0