Create Unit and Instrumentation test for Android project with dynamic features

喜你入骨 提交于 2021-01-29 19:47:42

问题


I have a project where I have main :app package. Besides that, the app contains of two dynamic features inside the same package, :features:A and :features:B.

The issue here is that I can't run Unit and Instrumentation tests (Espresso, UI Automator) because of the following error(s):

“AAPT: error: resource string/app_name (aka com.app.A.test:string/app_name) not found.” 

When I run tests(UI tests in this case) App compiles and works without any issues.

I figured out that error occurs on manifest merging, as it can be seen from complete error:

/Users/user/company/app/features/A/build/intermediates/tmp/manifest/androidTest/app/debug/manifestMerger7870721738992192959.xml:7:5-9:19: AAPT: error: resource string/app_name (aka com.app.A.test:string/app_name) not found.


回答1:


A library (A or B in the logs above) is requiring some value that is found in the merged manifest from the test variant. To fix it, you need to add the test dependency in the Dynamic Feature build.gradle:

dependencies {
    implementation project(":app")
    androidTestImplementation project(":app")
}


来源:https://stackoverflow.com/questions/60709733/create-unit-and-instrumentation-test-for-android-project-with-dynamic-features

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!