I have an application which consists of multiple gradle modules:
App -- main app module with dependencies to all submodules
|
|-- API - library module
| |-- Constants for authority etc.
|
|-- DB-Impl - library module
| |-- ContentProvider for the data specified in API
|
|-- Extension - library module
| |-- Dependency on API and test-dependency on DB-Impl
This is working fine when building and deploying the main apk. All modules are using the same sharedUserId in the manifest and can access the providers from DB-Impl.
However it gets complicated when I try to run instrumented tests for the different modules.
For example: I run the DB-Impl tests, that module gets installed separately on the device. When I then want to deploy the main app, or try to run it's tests, the apk install fails, because it also contains the providers, throwing an INSTALL_FAILED_CONFLICTING_PROVIDER
error.
The same happens for the extension module. It requires the database, which is usually included in the main app apk. When simply running the tests, they would fail because the provider wouldn't be installed. So I added an androidTestCompile
dependency on the DB-Impl module. Now this test apk also includes the provider definition an causes even more of the errors.
I tried adding a task dependency on the test tasks, so it would run uninstallAll
, however this only uninstalls the module it is called from, so I would have to manually uninstall every module that could come with the providers.
Is there a common strategy to avoid is problem?