android-sdk
android-sdk copied to clipboard
2 files found with path 'android-logger.properties' from inputs
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
feature-managementmodule includes the Optimizely Android SDK dependencyfeature-managementmodule includes theandroid-logger.propertiesfile atsrc/main/resourcesper Optimizely's documentation: https://docs.developers.optimizely.com/full-stack/docs/customize-logger-androidappmodule is dependent onfeature-managementmodule
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 Thanks for sharing. We'll take a look.
Happy New Year, any updates that can be shared?
@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.
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 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.
Great, thanks!