How to resolve Duplicate files copied in APK META-INF/rxjava.properties

风格不统一 提交于 2019-11-29 09:06:50

I had the same problem. The way I fixed it is adding the packagingOptions in app gradle as described in Duplicated file rxjava.properties

android {

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

I had the same issue.
In my case I am using Retrofit2 but I assume that the issue is with the rx libraries

This is the build.gradle (module:app) I am using and in my case works.

compile 'com.squareup.retrofit2:retrofit:2.0.2'
compile 'com.squareup.retrofit2:converter-gson:2.0.2'
compile 'com.squareup.retrofit2:adapter-rxjava:2.0.2'

compile 'io.reactivex:rxandroid:1.1.0' //<-use this
compile 'io.reactivex:rxjava:1.1.3'    //<-use this

compile 'com.squareup.okhttp3:okhttp:3.1.2'
compile 'com.squareup.okhttp3:logging-interceptor:3.0.1'

Anyway there is one better solution as you can see on the top

I encountered the same issue and fixed it by putting below code in app/build.gradle file. Please note that you have to put '*' at the end of path to exclude all the files inside the folder. You will have to change the path of files to be excluded in the below code based on error description.

compileSdkVersion 25
    buildToolsVersion "24.0.3"

    packagingOptions {
        exclude 'com/google/appengine/repackaged/org/apache/commons/codec/language/bm/*'
        exclude 'com/google/appengine/repackaged/org/codehaus/jackson/impl/*'
        exclude 'com/google/appengine/repackaged/org/apache/commons/codec/language/*'
    }

I had this issue today and fixed this problem

compile 'com.squareup.retrofit2:retrofit:2.2.0'
compile 'com.squareup.retrofit2:converter-gson:2.2.0'
compile 'com.jakewharton.retrofit:retrofit2-rxjava2-adapter:1.0.0'

//RxJava dependencies
compile 'io.reactivex.rxjava2:rxandroid:2.0.0'
compile 'io.reactivex.rxjava2:rxjava:2.0.2'
compile 'org.reactivestreams:reactive-streams:1.0.0'

I also have this problem ,I also used the same method as you ,but because I hava two module ,I only chang it in the module which dependency Rxjava,Finally I I fixed it is adding the packaginOptions in app gradle

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

I also have the same problem but easily removed duplicated "comment" all Rxjava related dependencies that it doesn't use in my code.

//RxJava removes or comment duplicated and not used dependencies.
      //  implementation 'com.squareup.retrofit2:adapter-rxjava:2.4.0'
       // implementation 'io.reactivex.rxjava2:rxandroid:2.0.2'
       // implementation 'io.reactivex.rxjava2:rxjava:2.1.13'

If you are facing this issue in 2019 and above this is most probably because you are using the deprecated RxJava 2 CallAdapter.Factory ie

com.jakewharton.retrofit:retrofit2-rxjava2-adapter

you will have to remove that dependency and add this

implementation 'com.squareup.retrofit2:adapter-rxjava2:latest.version'

please get the latest version from here

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!