I have an android project with several gradle modules. Dependencies beetween modules look like this:
app <-- coremodule <-- featuremodule
There are a resources in coremodule (strings and colors).
When I use them in layout from featuremodule everything is OK, they are avaliable and work as expected. But when I try to get them programmaticully in Activity from featuremodule I get an exception: Unresolved reference: R
So android:text="@string/res_from_core_module"
works and myTextView.setText(R.string.res_from_core_module)
doesn't work.
Have anyone ideas why it happens and how to solve this?
The reason for such behavior was adding 'coremodule' dependency with compileOnly.
build.gradle for app module looked like:
dependencies {
...
compileOnly project(path: ':coremodule')
...
}
if change compileOnly with implementation (or api) everything is OK
dependencies {
...
implementation project(path: ':coremodule')
...
}