openmobilehub / react-native-omh-auth

https://openmobilehub.github.io/react-native-omh-auth/
Apache License 2.0
0 stars 0 forks source link

Build Failure due to Duplicate 'META-INF/DEPENDENCIES' Files #35

Closed dzuluaga closed 1 month ago

dzuluaga commented 1 month ago

During the build process of our Android application, we encounter a failure at the :app:mergeDebugJavaResource task. The build process fails due to the presence of duplicate files (META-INF/DEPENDENCIES) found in multiple dependencies.

Error Output

* What went wrong:
Execution failed for task ':app:mergeDebugJavaResource'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.MergeJavaResWorkAction
   > 2 files found with path 'META-INF/DEPENDENCIES' from inputs:
      - /Users/[username]/.gradle/caches/transforms-4/4ea015df7084f40c6ea34b1d43f60e03/transformed/jetified-httpclient-4.5.13.jar
      - /Users/[username]/.gradle/caches/transforms-4/9cb5e044b077b202c6f6f033691dc4ae/transformed/jetified-httpcore-4.4.15.jar

Steps to Reproduce

  1. Initiate the build process for the debug version of the app.
  2. Observe the failure during the resource merging phase.

Potential Temporary Solution

I have added a packagingOptions block in the build.gradle file to handle the duplicate file issue:

android {
    ...
    packagingOptions {
        exclude 'META-INF/DEPENDENCIES'
        // or
        // pickFirst 'META-INF/DEPENDENCIES'
    }
}

This resolves the build issue by either excluding the META-INF/DEPENDENCIES file or selecting the first instance of the file.

Question

Is the solution mentioned above a recommended permanent fix, or should a different approach be taken to resolve this issue in a more sustainable way?

Esemesek commented 1 month ago

Investigated this issue for a while and couldn't find any sustainable permanent solution. It seems like there is no way to tell dependencies to exclude/merge/pick some of the duplicated files nor it is possible to set packagingOptions for the app that would consume our library. For now, we should mention this issue with a way to fix it.

dzuluaga commented 1 month ago

Sounds good. Thanks. Let's keep an eye on it.