Android App bundle Cannot find symbol variable for resource

僤鯓⒐⒋嵵緔 提交于 2019-12-13 04:58:02

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!