简体   繁体   English

动态功能。 错误:处理清单失败

[英]Dynamic feature. Error: failed processing manifest

I have a base module and I'd wanted to create feature one which contains some libs. 我有一个基本模块,我想创建一个包含一些库的功能。 One of this libs was into the base module and when I moved it to the feature and removed it from base one I got an error: 其中一个库位于基本模块中,当我将其移至功能部件并将其从基本模块中删除时,出现了一个错误:

APT: error: resource style/SDKTheme.Translucent (aka io.app.dev.debug:style/SDKTheme.Translucent) not found. APT:错误:找不到资源样式/SDKTheme.Translucent(又名io.app.dev.debug:style / SDKTheme.Translucent)。

It works if base and feature modules have this dependency, but in this case I lost a profit of separating. 如果基本模块和功能模块具有此依赖性,则此方法有效,但是在这种情况下,我失去了分离的利益。

I found a known issue: 我发现了一个已知问题:

In a dynamic feature module's manifest, you should not reference resources that don't exist in the base module. 在动态功能模块的清单中,您不应引用基本模块中不存在的资源。 That's because, when Google Play generates your app's base APK, it merges manifests for all modules into that of the base APK. 这是因为,当Google Play生成您应用的基本APK时,它将所有模块的清单合并到基本APK的清单中。 So, resource linking breaks if the base APK's manifest references resources that don't exist in the base APK. 因此,如果基本APK的清单引用了基本APK中不存在的资源,则资源链接会中断。

is this my problem? 这是我的问题吗?

Yes, that exactly is your problem. 是的,那正是您的问题。

Solutions are: 解决方案是:

  1. Have the actual implementation of your style in your feature module, but create an empty declaration of the style in your base module. 在功能模块中具有样式的实际实现,但是在基本模块中创建样式的空声明。 Example of how the empty declaration will look is: 空声明的外观示例如下:

<style name="SDKTheme.Translucent" />

What happens is that the manifest merger picks up this style during merging, even though the actual implementation of the style is being introduced through the feature module's styles. 发生的事情是清单合并在合并过程中采用了这种样式,即使该样式的实际实现是通过要素模块的样式引入的。

  1. Keep style declarations in the base module. 将样式声明保留在基本模块中。 Although, this only works if all resources referenced are in the base module as well. 虽然,这仅在所有引用的资源也都在基本模块中时才有效。

For more information, read this blog post by Ben Weiss - https://medium.com/androiddevelopers/a-patchwork-plaid-monolith-to-modularized-app-60235d9f212e 有关更多信息,请阅读Ben Weiss撰写的此博客文章-https: //medium.com/androiddevelopers/a-patchwork-plaid-monolith-to-modularized-app-60235d9f212e

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM