DataBinderMapperImpl not adding mapper for module

Viewed 136

I'm facing exactly the same problem described here: DataBinding V2 Crashes in multi module android Projects But there is not any answer on that question.

The problem is that the DataBinderMapperImpl generated class is not being correctly generated:

public class DataBinderMapperImpl extends MergedDataBinderMapper {
  DataBinderMapperImpl() {
    addMapper(new com.xxx.appmodule.DataBinderMapperImpl());
  }
}

If I modify that class and (manually) add a new line for the missing mapper impl:

addMapper(new com.xxx.appmodule.DataBinderMapperImpl());
addMapper(new com.xxx.missingmodule.DataBinderMapperImpl());

Then everything works as expected, but obviously this is not a solution.

Tried with both:

    buildFeatures {
        dataBinding true
    }
// and
    dataBinding {
        enabled = true
    }

But the result is the same.

The most annoying thing is that this behaviour is random. Sometimes the compiler/plugin/??? works ok and the class is correctly generated.

This started to happen just after migrating the project to AndroidX.

Any help would be appreciated!

UPDATE: This seems to be related to the kotlin-kapt plugin. Currently we are applying that plugin in both module and app build.gradle. If I remove the apply plugin: 'kotlin-kapt' from the module, then the data binding mapper is added in the app's module DataBinderMapperImpl:

  @Override
  public List<DataBinderMapper> collectDependencies() {
    ArrayList<DataBinderMapper> result = new ArrayList<DataBinderMapper>(2);
    result.add(new androidx.databinding.library.baseAdapters.DataBinderMapperImpl());
    result.add(new com.xxx.missingmodule.DataBinderMapperImpl());
    return result;
  }

But this has no sense at all for me. What am I missing?

0 Answers
Related