DataBindingUtil.inflate returns null

Safa Orhan
Jun 29, 2021

Problem

In a recent multi-module Android project, I was getting null from DataBindingUtil.inflate(…) call.

You can get this error from YourDataBinding.inflate(…) or YourDataBinding.setContentView(…) calls too.

After hours of spending time to debug it, I believe I found out the reason:

There was some kind of package name clash in the generated code.

The error and its stack trace does not say anything about it but I realized I enabled data binding in two different modules of which AndroidManifest.xml manifests the same package name.

Solution

Make sure all of the data binding enabled modules in your projects have unique package names declared in the AndroidManifest.xml

--

--