Android Instant Apps - Cannot find symbol from underlying asset
I have a base function module and a function module (you can call it "child"). The base functional module has a file with strings.xml files containing:
<resources>
<string name="app_string">Test String</string>
</resources>
I am trying to refer to this string resource in a "child" function like below:
int resId = R.string.app_string;
Android Studio seems to respect this link and will even direct me to the resource app_string
when I click on it. However, during compilation, I am greeted with the following error message:
Error:(13, 25) error: cannot find symbol variable app_string
There is also a dependency in the Gradle build file for my "child" function:
dependencies {
...
implementation project(':base')
}
I also tried compile project(':base')
but didn't have time.
Is there something glaring I am missing?
source to share
Your base and child modules have different package names - let's say they com.example.base
and com.example.child
. Each of them contains its own set of resources, and their IDs will be collected in separate R packages:
-
com.example.base.R
-
com.example.child.R
Since you are trying to access a resource defined in the base module, you need to reference it with the fully qualified variable name that is com.example.base.R.string.app_string
.
source to share