Android feature module dependency on another module not finding resources

Viewed 1012

I have my base module(Base), a dynamic feature module(A) and a common module(Common) that is not a a dynamic feature, its a library. When I add Common as a dependency of A, I'm able to use classes from it but my build fails because it can't find the resources (error: cannot find symbol R.drawable.myimage) from the Common library.

dependencies {
     implementation project(":Common")
     implementation project(':Base')
}

Is this a dynamic feature constraint or is something causing this?

3 Answers

Turns out R.id.resource will only get the resources from the feature module, com.yourdomain.base.R.id.resource will reference resources of the base module which has access to the resources of the library module.

This solved my issue.

Import your library module (Common) by using

File --> New --> Import Module

you can always try a

Invalidate Caches & Restart

(awkwardly solves most issues with Android Studio)

Related