Android为Retrofit和Retrofit Adapter获取DuplicateFileException错误

时间:2017-04-13 18:19:50

标签: android gradle retrofit

在项目上安装此库之后:

compile 'io.reactivex.rxjava2:rxandroid:2.0.1'
compile 'io.reactivex.rxjava2:rxjava:2.0.1'
compile 'com.squareup.retrofit2:adapter-rxjava:2.1.0'

我收到此错误:

Error:Execution failed for task ':app:transformResourcesWithMergeJavaResForDebug'.
com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK META-INF/rxjava.properties
File1: /Users/mahdi/.gradle/caches/modules-2/files-2.1/io.reactivex.rxjava2/rxjava/2.0.1/57f850a6b317e5582f1dbaff10a9e7d7e1fcdcfb/rxjava-2.0.1.jar
File2: /Users/mahdi/.gradle/caches/modules-2/files-2.1/io.reactivex/rxjava/1.1.5/ece7b5d0870e66d8226dab6dcf47a2b12afff061/rxjava-1.1.5.jar

我不确定是什么问题,有些文件像我的解决方案一样安装它们。

packagingOptions {
    exclude 'META-INF/io.reactivex.rxjava2/rxjava/2.0.1/57f850a6b317e5582f1dbaff10a9e7d7e1fcdcfb/rxjava.properties'
    exclude 'META-INF/io.reactivex/rxjava/rxjava.properties'
}

1 个答案:

答案 0 :(得分:3)

问题已解决:

packagingOptions {
    exclude 'META-INF/rxjava.properties'
}