Android+Kotlin Multi+Module: Failure during processDebugAndroidTestResources

I’m trying to upload my codebase to sonarqube using gradle

/gradlew sonar someargs

The error message:

* What went wrong:
Execution failed for task ':features:library:processDebugAndroidTestResources'.
> A failure occurred while executing$TaskAction
   > Android resource linking failed
     ERROR:/feature/library/build/intermediates/packaged_res/debug/layout/ui_details.xml:14: AAPT: error: resource style/content_description (aka feature.library.test:style/content_description) not found.

How do I deal with resource linking issue without having to manually move resource values around?
My app is a android multi-module project. We have developers owning their gradle project and noticed some would reference resources strings or styles that doesn’t belong to their modules.
Module A using Module B resources. This is all fine because the resources are merged.

How do I go about this without creating additional code to complain they are using resources from modules they are not importing or doesn’t belong to their module.

Hello @ellysmores,

The thing is that currently sonar task depends on your *compile tasks, so when you execute ./gradlew sonar, firstly your compile tasks are executed and then the analysis is executed.

In your case it seems to not be enough, so it seems to me that the best solution for you will be to build the project separately and then exclude your compile tasks from sonar task execution. For example, by using .\gradlew sonar -x yourCompileTask

Note, that if you don’t build your project at all and run the analysis with excluded compile tasks, the results of the analysis will be less precise. As analyzers are using generated binaries and your dependencies, to resolve semantic information.