首页 > 解决方案 > 无法使用 dynamicFeatures 运行 Espresso

问题描述

当我尝试运行检测单元测试时,我遇到了启用动态功能的清单合并问题。

我尝试将模块添加为“androidTestImplementation 项目”,但由于它们是“功能”而不是“模块”,因此它不起作用。无论如何,我觉得这一步太晚了,因为此时添加动态功能已经失败。这是清单合并问题:

insertion/build/intermediates/tmp/manifest/androidTest/debug/manifestMerger.xml  
Android resource linking failed 

构建.gradle

    android {
    ...
    dynamicFeatures = [":feature1", ":feature2"]
    }

其他人有同样的问题吗?

标签: androidandroid-studioandroid-espresso

解决方案


我通过在我的动态功能模块中为 androidTest 添加应用程序依赖项来修复它

implementation project(':app')
androidTestImplementation project(':app')

推荐阅读