问题
I am trying to access the resource which is in base.apk
, As documented I am placing all common source and resource in base app. But when I try to access the same from dynamic-module its giving error: cannot find symbol variable <resource>
What I have noticed is the R package in the dynamic module is different than the base app. But the IDE is not complaining anything.
Appreciate if anyone can help with this issue.
Thanks.
回答1:
You may try to remove the R import statement generated in the dynamic module and use the same as in the App module.
回答2:
You'll have to explicitly import the R
file for the module you're requesting the resource from. For Kotlin I use import aliases like this:
import foo.bar.base.R as Rbase
So instead of foo.bar.base.R.dimen.bar_foo_size
I can write Rbase.dimen.bar_foo_size
. This also makes it fairly explicit to see where a resource is coming from compared to having to look into the imports.
来源:https://stackoverflow.com/questions/51253956/android-app-bundle-cannot-find-symbol-variable-for-resource