[英]Android dynamic feature modules dependencies
so I have a couple of features that share common code - let's call them "feature1" and "feature2".所以我有几个共享通用代码的功能——我们称它们为“feature1”和“feature2”。 I can't add the shared code as dependencies for "feature1" and "feature2" - Android studio throws the following error:
我无法将共享代码添加为“feature1”和“feature2”的依赖项 - Android studio 抛出以下错误:
Multiple APKs packaging the same library can cause runtime errors.
打包同一个库的多个 APK 可能会导致运行时错误。 Adding the above library as a dependency of the base module will resolve this issue by packaging the library with the base APK instead.
将上述库添加为基本模块的依赖项将通过将库与基本 APK 打包来解决此问题。
So I thought I just create another dynamic feature module - let's call it "core" - to deliver the shared dependencies there.所以我想我只是创建另一个动态功能模块——我们称之为“核心”——在那里提供共享依赖项。 Which also works, kind of.
这也有效,有点。 I can access all the java classes from "core" inside "feature1" and "feature2", but as soon as I want to access a resource I get an ResourceNotFoundException.
我可以从“feature1”和“feature2”中的“core”访问所有 java 类,但只要我想访问资源,就会得到 ResourceNotFoundException。 The features are deliver Fragments that call
SplitCompat.install(context)
in their onAttach()
function.这些功能是在其
onAttach()
function 中调用SplitCompat.install(context)
的交付片段。
So my question is - is it even possible to have a dynamic feature module where common code is stored, or should this all go in the app?所以我的问题是 - 是否有可能拥有一个存储公共代码的动态功能模块,或者应该在应用程序中使用 go?
Thanks & Regards, Romanski谢谢和问候, 罗曼斯基
Now support for feature on feature dependencies have been introduced in the latest release of gradle:现在,在最新版本的 gradle 中引入了对功能依赖项的功能支持:
https://developer.android.com/studio/releases/gradle-plugin#feature-on-feature https://developer.android.com/studio/releases/gradle-plugin#feature-on-feature
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.