Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MergeJavaResource fails because of duplicate .proto files #684

Open
ADVavvas opened this issue Mar 22, 2023 · 0 comments
Open

MergeJavaResource fails because of duplicate .proto files #684

ADVavvas opened this issue Mar 22, 2023 · 0 comments

Comments

@ADVavvas
Copy link

There are 3 modules in the project: app, app-common, app-native.

  • app-common is a Java module that contains the .proto classes that get compiled to Java. Both other modules will depend on the Java classes.

  • app-native is an Android module that contains a C++ library that also needs to compile the same .proto classes but in C++ (and also depends on the Java classes).

  • app depends on both.

At the moment, since app-native requires both Java and C++ compiled protobuf classes it declares 2 dependencies:

implementation project(path: ':app-common') // Java dependencies
protobuf project(path: ':app-common') // .proto files to be recompiled but in C++

This leads to duplicate .proto files when merging:

> A failure occurred while executing com.android.build.gradle.internal.tasks.MergeJavaResWorkAction
  > 2 files found with path 'Foo.proto' from inputs:
     - /Users/..../app-native/build/intermediates/library_java_res/debug/res.jar
     - /Users/.../app-common/build/libs/app-common.jar

Adding packaging options to app-native e.g. resources.excludes.add("*.proto") seems to have no effects.
Excluding the .proto from app-common (jar { exclude '**/*.proto') somewhat works for the user defined protos, but still fails with the same error caused by google/protobuf/Foo.proto` instead.

I realise the project configuration might be unconventional but I don't know what an alternative could be, so any help is appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant