optimizely / android-sdk

Android SDK for Optimizely Feature Experimentation and Optimizely Full Stack (legacy)
https://docs.developers.optimizely.com/experimentation/v4.0.0-full-stack/docs/android-sdk
Apache License 2.0
55 stars 39 forks source link

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

Closed justinpapezsonos closed 1 year ago

justinpapezsonos commented 1 year ago

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

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.

jaeopt commented 1 year ago

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

justinpapezsonos commented 1 year ago

Happy New Year, any updates that can be shared?

jaeopt commented 1 year ago

@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.

justinpapezsonos commented 1 year ago

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.

jaeopt commented 1 year ago

@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.

justinpapezsonos commented 1 year ago

Great, thanks!