Java – Operating system independent path found for multiple files as ‘android/databinding/DataBindingComponent.java

Operating system independent path found for multiple files as ‘android/databinding/DataBindingComponent.java… here is a solution to the problem.

Operating system independent path found for multiple files as ‘android/databinding/DataBindingComponent.java

I’m getting this error while building in android studio :

Error:Execution failed for task
‘:app:transformResourcesWithMergeJavaResForDebug’.

More than one file was found with OS independent path ‘android/databinding/DataBindingComponent.java’

I used this library applied a universal adapter with data binding.
My application already has DataBinding turned on

  dataBinding {
    enabled = true
  }

The example in this library works fine, but I don’t know why it replicates the DataBindingComponent in my application.
Any clues to figure it out?

Solution

I’m having this issue when updating Android Studio to version 3.0.
Fix by adding packagingOptions:

android{
    packagingOptions {
        exclude 'android/databinding/DataBinderMapper.java'
        exclude 'android/databinding/DataBindingComponent.java'
        exclude 'android/databinding/DynamicUtil.java'
    }
}

Related Problems and Solutions