Execution failed for task...More than one file was found with OS independent path'META-INF/rxjava...

项目导入第三方包的时候出现

Execution failed for task':app:transformResourcesWithMergeJavaResForDebug More than one file was found with OS independent path"META-INF/rxjava.properties'的错误,如下图所示:

Execution failed for task...More than one file was found with OS independent path'META-INF/rxjava...

查看Gradle Console打印的日志为:

Execution failed for task...More than one file was found with OS independent path'META-INF/rxjava...

解决方案是:

在app下的build.gradle的配置文件的android闭包中添加如下:

packagingOptions {
    //解决编译时com.android.builder.merge.DuplicateRelativeFileException: More than one file was found with OS independent path 'META-INF/rxjava.properties'这个错误
    exclude 'META-INF/rxjava.properties'
}

点击Sync Now同步一下重新编译OK。