Skip to content Skip to sidebar Skip to footer

Using Rxjava 2 And Retrofit 2, Adapter Version Issue

I've added a new library module to existing application module in Android Studio. The main difference was adding RxJava 2 and Retrofit 2. After updating build.gradle of new module

Solution 1:

You should use the official adapter for the second version of RxJava:

compile 'com.squareup.retrofit2:adapter-rxjava2:2.2.0// works with RxJava 2

The fact that adapter has version 2.*.* does not mean that it is intended for use with RxJava 2, as I thought.

compile 'com.squareup.retrofit2:adapter-rxjava:2.1.0'// won't work with RxJava 2

Previously, you should use a temporary version: Here is the repository of Jake Wharton with Retrofit 2 to RxJava 2 adapter.

I found this problem using command gradlew :app dependencies in Android Studio terminal, where the app is name of my library module. There I looked for "rxjava" keyword and found different versions of it.

Update: On February, 21 Square published the official version of adapter, as Darshan Mistry pointed out in a comment. Answer updated.

Solution 2:

Need to remove duplicate library from the project if added multiple times with different version.

or if two libraries which are dependent and have different version thn both will have different meta inf version which will cause this type of issue.

How to check Dependency/hierarchy Refere this answer

In your case there are multiple rxjava.properties in jar meta inf So to ignore that duplicate entry exclude it from the application's build.gradle in android tag

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

Post a Comment for "Using Rxjava 2 And Retrofit 2, Adapter Version Issue"