android-sdk icon indicating copy to clipboard operation
android-sdk copied to clipboard

2 files found with path 'android-logger.properties' from inputs

Open justinpapezsonos opened this issue 2 years ago • 1 comments

Issue

Task :app:mergeDebugJavaResource fails when trying to compile a multi-module Android application.

Error

> Task :app:mergeDebugJavaResource FAILED

FAILURE: Build failed with an exception.

* 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 'android-logger.properties' from inputs:
      - /Users/justinpapez/Downloads/OptimizelyCustomLogger/feature-management/build/intermediates/library_java_res/debug/res.jar
      - /Users/justinpapez/.gradle/caches/transforms-3/1f7e4dfbf22809ee6d48c3a5c69a9d14/transformed/android-sdk-3.13.2/jars/classes.jar
     Adding a packagingOptions block may help, please refer to
     https://developer.android.com/reference/tools/gradle-api/7.3/com/android/build/api/dsl/ResourcesPackagingOptions
     for more information

Application Structure

.
├── app
│   ├── build.gradle
│   ├── ...
│   └── src
│       └── ...
├── ...
├── build.gradle
├── feature-management
│   ├── build.gradle
│   ├── ...
│   └── src
│       ├── ...
│       ├── main
│       │   ├── ...
│       │   └── resources
│       │       └── android-logger.properties
├── ...
└── settings.gradle

Implementation Details

Environment Details

  • macOS Monterey
  • Apple M1 Pro
  • Android Studio Dolphin | 2021.3.1 Patch 1
  • openjdk 11.0.17 2022-10-18 LTS

Miscellaneous

Invoke the build Gradle task alongside of this bare bones multi-module Android sample app to reproduce the behavior outlined in this GitHub Issue.

justinpapezsonos avatar Nov 11 '22 01:11 justinpapezsonos

@justinpapezsonos Thanks for sharing. We'll take a look.

jaeopt avatar Nov 15 '22 17:11 jaeopt

Happy New Year, any updates that can be shared?

justinpapezsonos avatar Jan 03 '23 19:01 justinpapezsonos

@justinpapezsonos I see this issue when you have a logger property file in your own module. You can try to add this to your app build.gradle:

    packagingOptions {
        pickFirst '**/android-logger.properties'
    }

Let us know if it fixes your issue.

jaeopt avatar Jan 03 '23 21:01 jaeopt

Does pickFirst have deterministic behavior? As in, does pickFirst guarantee that the android-logger.properties file in my Android project will always be chosen before the android-logger.properties file in my Gradle cache? I've not been able to find documentation that states that pickFirst is deterministic.

justinpapezsonos avatar Jan 03 '23 21:01 justinpapezsonos

@justinpapezsonos I also see lack of clear ordering definition, but it's expected be determined by the dependency order, and we observe deterministic in similar scenarios. If it's an option for you, you can also consider moving the logger property file to the main app, which will override the same-named resources from libs without error.

jaeopt avatar Jan 04 '23 17:01 jaeopt

Great, thanks!

justinpapezsonos avatar Jan 04 '23 18:01 justinpapezsonos