0

I'm trying to clean up our codebase a bit by modularization.

My target structure is something like this:

app
feature1
  models
  view
  …etc
feature2
  models
  view
  …etc

So I've got a module for each feature, and underneath I have a submodule structure which is basically the same per feature module.

Everything looks find in the project view, but when I try to build or sync, I get errors like:

Execution failed for task ':app:mergeDebugJavaResource'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
   > More than one file was found with OS independent path 'META-INF/models_debug.kotlin_module'.

So I basically get what the issue here is: I got two or more modules with the same name. Right now my solution is to basically add a prefix to each module name:

app
feature1
  feature1-models
  feature1-view
  …etc
feature2
  feature2-models
  feature2-view
  …etc

which works fine, but I just don't like the redundancy here when looking at my project view.

So does anybody know a way for me to keep my target module structure?

Edit: Seems like this might have something to do with the Kotlin Compiler, so added specific tags for that.

Boris
  • 159
  • 11

1 Answers1

0

As a simple solution, you can try to exclude those files from the packaging. Add this to your build.gradle:

packagingOptions {
    exclude 'META-INF/models_debug.kotlin_module'
}
Konstantin Raspopov
  • 1,565
  • 1
  • 14
  • 20
  • That would probably work. I'm just unfamiliar with those files and thus don't know what the possible impact would be to exclude them. – Boris Feb 25 '21 at 13:09
  • @Boris you may find more information in this answer https://stackoverflow.com/a/45235642/2314529 – Konstantin Raspopov Feb 25 '21 at 13:16
  • Thanks. I went ahead with my solution outlined in my question (using unique names), as I didn't like the possible caveats of any of those proposed solutions. Maybe this is just something that needs to be "fixed" in the Kotlin compiler. – Boris Mar 09 '21 at 08:32