问题
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