RxJava 1 and RxJava 2 in the same project [duplicate]

╄→尐↘猪︶ㄣ 提交于 2020-01-11 11:03:54

问题


Our project uses RxJava 1:

compile 'io.reactivex:rxjava:1.1.6'

There is a library we use that uses RxJava 2 internally:

compile 'io.reactivex.rxjava2:rxjava:2.0.9'

When I do ./gradlew assembleDebug I get this error:

com.android.build.api.transform.TransformException:com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK META-INF/rxjava.properties
      File1: /Users/darklord/.gradle/caches/modules-2/files-2.1/io.reactivex/rxjava/1.1.6/2586312cd2b8a511e4c6236736f5a039fc0f2273/rxjava-1.1.6.jar
      File2: /Users/darklord/.gradle/caches/modules-2/files-2.1/io.reactivex.rxjava2/rxjava/2.0.9/a5aad74623ade11162dd53cdf0645a51b12221a0/rxjava-2.0.9.jar

I think it is said that RxJava 1 and RxJava 2 can be used at the same time, why I am still getting this error?


回答1:


rxjava.properties file is not required at run time.

So you can exclude the file while packaging your android app by setting packagingOptions in app/build.gradle file as shown below.

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


来源:https://stackoverflow.com/questions/44792066/rxjava-1-and-rxjava-2-in-the-same-project

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