Main project and Submodule flavors don't work together

I have a main Android project, which depends on a submodule.

The main project has flavors defined in Gradle.

Also the submodule has a few flavors defined. This should be logical - to be able to have flavors for both projects. For example in the submodule:

productFlavors {
    flavorName {
      }
    }

But this does not work - The build crashes with a message saying that submodule resources are not found in the main project.

But when I delete flavors from the submodule, everything works fine.

It seems to mix the build order when flavors are defined for the subproject, could this be true?

What am I missing? Is it even possible for both main and sub projects to have flavors?