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

后端 未结 7 1815
渐次进展
渐次进展 2020-12-18 18:20

I am using rxjava and rxvolley on my android aplication. When I try to run it I get this error

Execution failed for task \':testapp:transformResourcesWithMer         


        
相关标签:
7条回答
  • 2020-12-18 18:50

    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'
    }
    
    0 讨论(0)
  • 2020-12-18 18:56

    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/*'
        }
    
    0 讨论(0)
  • 2020-12-18 18:57

    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'
    
    0 讨论(0)
  • 2020-12-18 18:58

    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

    0 讨论(0)
  • 2020-12-18 19:01

    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'
    
    0 讨论(0)
  • 2020-12-18 19:04

    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

    0 讨论(0)
提交回复
热议问题