简体   繁体   English

Android 动态特性模块依赖

[英]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.

相关问题 Android 带匕首刀柄的动态功能模块 - Android Dynamic Feature modules with Dagger Hilt 具有 Android 架构导航的动态功能模块之间的 startActivityForResult() - startActivityForResult() between Dynamic Feature Modules with Android Architecture Navigation Android 动态特性模块不工作,无法正常访问资源 - Android dynamic feature modules do not work, cannot access resources properly Android 动态特征 - Android Dynamic Feature Android:依赖项和模块的Proguard规则 - Android: Proguard rules for dependencies and modules Android-库模块的Gradle依赖关系 - Android - Gradle dependencies of Library Modules 在 android 上重构为动态功能模块时,构建失败并显示“task:features:catalog:createDebugCompatibleScreenManifests FAILED” - Build fails with 'task :features:catalog:createDebugCompatibleScreenManifests FAILED' while refactoring to dynamic feature modules on android 是否可以使用动态功能模块和 Koin 构建项目? - Is it possible to build a project with Dynamic feature modules and Koin? 具有即时/(动态)功能模块的导航组件 - Navigation component with instant/(dynamic-)feature modules 在动态功能模块之间共享信息 - Share information between dynamic feature modules
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM