遇见BUG之 “Dependent features configured but no package ID was set”

出错表现

Execution failed for task ':app:processDebugResources'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
   > AAPT2 aapt2-4.0.2-6197926-windows Daemon #0: Unexpected error during link, attempting to stop daemon.
     This should not happen under normal circumstances, please file an issue if it does. 
解决方法

Dependent features configured but no package ID was set. 

先上解决方法,着急同学拿去用,方法其实很简单

检查作为库依赖的Module中是否有因为测试而设置的id 'com.android.application'
将其改回id 'com.android.library'即可

此中情况多出现在多Module开发时,为开发方便、编译速度快,前期将Module作为单独APP进行,后主APP依赖时,未及时修改当前Module的编译类型导致
解决思路来自:stackoverflow 在此感谢陌生的程序猿伙伴

简单分析

AAPT: Android Asset Packaging Tool的缩写,是编译和打包资源的工具。而aapt2是在aapt上做了优化。
因此问题出现在资源打包时,事实证明也是如此,在执行“Sync project with gradle files”时,也就是右数第三个按钮,并未出现错误提示

在这里插入图片描述

资源问题,一般开发过程中IDE便已经给出提示,所以是资源合并的时候,那就涉及多Module之间的资源合并。
最后再依次检查Module的配置,应该就能发现问题。
以上是简单思路,我是根据stackoverflow的回答才有的想法,再次感谢~
————————————————

转载于:https://blog.csdn.net/u014235093/article/details/109116602

猜你喜欢

转载自blog.csdn.net/weixin_42602900/article/details/128236831