I am using a android project as library, which are using the following library added as a jar
okhttp-2.2.0.jar
okhttp-urlconnection-2.2.0.jar
okio-1.2.0.jar
retrofit-1.9.0.jar
And in my main project I am using the following library
compile 'com.squareup.retrofit2:retrofit:2.1.0'
compile 'com.squareup.retrofit2:converter-gson:2.1.0'
compile 'com.squareup.okhttp3:okhttp:3.4.1'
compile 'com.google.code.gson:gson:2.7'
And there are some other library, but after some research I have found that these are causing the problem.
The app runs fine, but crashes with the following error when I tried to consume any web service using retrofit
java.lang.NoClassDefFoundError: Failed resolution of: Lokio/ForwardingTimeout
In my app level gradle file I have added
multiDexEnabled true
Also I tried adding
configurations{
all*.exclude module: 'okhttp-2.2.0'
all*.exclude module: 'okio'
}
And I tried adding retrofit gradle dependency like following
compile ('com.squareup.retrofit2:retrofit:2.1.0') {
exclude group: 'okio'
}
compile ('com.squareup.retrofit2:converter-gson:2.1.0') {
exclude group: 'okio'
}
None of these worked, my project was working fine before adding the library project. Any help would be appreciated.