How to fix "Cannot resolve symbol" in a library module without flavors in Android Studio?

Viewed 292

This is my project setup:

  • I have 3 modules in an Android Studio project (app, feature & theme):

    Android Studio modules

  • Important: Only :app & :theme modules have flavors. :feature module has no flavors.

    flavorDimensions("product")
    
    productFlavors {
        paid { }
        demo { }
        free { }
    }
    

    This makes Build Variants look this way:

    enter image description here

  • This is the dependency graph:

    enter image description here

So:

  • The :app module can see all the resources in :theme module because all Build Variants match

  • Since the :feature module has no flavors, I have declared the :theme dependency this way:

    implementation project(configuration: 'default', path: ':theme')

    this makes the project to build successfully ✅ ✅ ✅

  • However, the :feature module can't see resources defined in the :theme module.

  • If I remove configuration: 'default' from the dependency declaration, I get this error:

    ERROR: Unable to resolve dependency for ':feature@debug/compileClasspath': Could not resolve project :theme.
    
  • This is a layout file in the :feature module:

    enter image description here

  • The product_name String is declared in the :theme module in different directories matching the flavor names

The question is:

How do I make the :feature module to recognize the resources declared in the :theme module without having to declare flavors in the :feature module?

1 Answers
Related