android - 如何共享 "base feature"模块中包含的库资源

标签 android android-resources android-instant-apps

我的android项目结构如下

  • 应用模块
  • 基本功能模块
  • 功能模块
  • 本 map 书馆项目
  • 远程库

当我尝试将本地库项目包含在基本功能模块中时 api 或实现,该功能要么由于找不到资源而无法编译,要么在运行时抛出相同的错误。 现在我想知道我是否误解了一点。文档说基本功能模块旨在共享公共(public)代码和资源,但似乎它不涵盖库案例。

当我尝试在功能模块中包含相同的库时,会引发运行时资源未找到错误。

最佳答案

在功能模块中引用基本模块中的资源时,您需要使用完整的 packageName 限定符。

这是因为在即时应用程序中它们将属于另一个 namespace 。

因此:

R.id.resource 将指向您的功能模块的资源 com.yourdomain.appbase.R.id.resource 将引用您的基本模块的资源

关于android - 如何共享 "base feature"模块中包含的库资源,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44921868/

相关文章:

android - ibeacon(信标)能否模仿NFC近距离发送通知?

android - 在具有大量文本行和样式的 EditText 中启用 2D 滚动

android - 如何让 Android BroadcastReceiver 抵抗意外停止?

android - WebCachedImageView 错误 res xml 命名空间

Android:如何从其他Android应用程序访问资源文件夹

android - Instant App Architecture 的 Crashlytics list 合并问题

android - 可用的 Android 设备传感器列表

android - 如何在android中存储具有相同名称但扩展名不同的资源文件

android - 错误 : style attribute '@android:attr/windowExitAnimation' not found

android - React native 和 Android Instant Apps 将如何合作?有什么想法吗?