I solve my problems with instrumented tests in dynamic modules by creating an AndroidManifest.xml
in the folder src/debug
of the dynamic module and placing:
<manifest xmlns:dist="http://schemas.android.com/apk/distribution"
xmlns:tools="http://schemas.android.com/tools"
package="com.example.poc.auth">
<!-- Note that we replace here our delivery from `on-demand` to `install-time` and put on the debug
folder so in tests this performs as a monolithic application and avoid non found
errors. Note also that this manifest need to be in `debug` folder rather
than `androidTest` folder. See https://mcmap.net/q/361227/-androidmanifest-in-androidtest-directory-being-ignored>
<dist:module
dist:instant="false"
dist:title="Feature Module Auth Test"
tools:node="replace">
<dist:delivery>
<dist:install-time />
</dist:delivery>
<dist:fusing dist:include="true" />
</dist:module>
</manifest>
This will make the application works as monolithic .apk
on tests which is great for local and CI/CD small intrumentation tests.
If you need to test the delivery itself in a end-to-end test like suggested here, I am not sure if this will have a impact, but if it has you can still create a flavor for your end-to-end test that override again the manifest.