Android 动态特性模块依赖

Android dynamic feature modules dependencies

所以我有几个共享通用代码的功能 - 我们称它们为 "feature1" 和 "feature2"。我无法将共享代码添加为 "feature1" 和 "feature2" 的依赖项 - Android 工作室抛出以下错误:

Multiple APKs packaging the same library can cause runtime errors. Adding the above library as a dependency of the base module will resolve this issue by packaging the library with the base APK instead.

所以我想我只是创建了另一个动态功能模块——我们称之为 "core"——以在那里提供共享依赖项。这也有效,有点。我可以从 "feature1" 和 "feature2" 中的 "core" 访问所有 java 类,但是一旦我想访问资源,我就会收到 ResourceNotFoundException。这些功能是交付在其 onAttach() 函数中调用 SplitCompat.install(context) 的片段。

所以我的问题是 - 是否有可能拥有一个存储公共代码的动态功能模块,或者这一切都应该放在应用程序中吗?

感谢和问候,罗曼斯基

现在 gradle 的最新版本中引入了对功能依赖项功能的支持:

https://developer.android.com/studio/releases/gradle-plugin#feature-on-feature