I added a module to my project and now I want to put there some fragments.
In my fragment I initialize data binding like this
class MyTestFragment : Fragment() {
private lateinit var binding:
MyTestFragmentNewBinding
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
// Inflate the layout for this fragment
binding = DataBindingUtil.inflate(inflater, R.layout.my_test_fragment_new, container, false)
binding.test = DataModel("zzz")
return binding.root
}
}
Then in Android Studio I click make module
and it compiles. After it I try to run my app and see two errors
Unresolved reference: MyTestFragmentNewBinding
and
import com.example.common.databinding.MyTestFragmentNewBinding
I see Unresolved reference: databinding
I tried a lot of solutions like rebuilding, invalidating cache, closing and reopening Android Studio, nothing works.
The most interesting thing is that after renaming of layout.xml and after importing new reference to a binding class it works till the next build. Than the same issue.
Did someone have something like this? What can be wrong? It seems that in my second module probably something delete binding class during build or something like this