jrh
jrh

Reputation: 764

Android - Replace lib jar with gradle jar

I have gson2.2.4.jar in my android project folder(/libs/gson2.2.4.jar) and retrofit is conflicting with this. For that, I have to use gson 2.8.5 version. I cannot delete lib/gson2.2.4.jar as it is copied via a build tool. is there anyway override this libs folder version with gradle entry?

Thanks

Upvotes: 0

Views: 162

Answers (3)

nitinkumarp
nitinkumarp

Reputation: 2160

You need access your build tool code that is adding lib/gson2.2.4 and remove the logic which is adding that lib. If you don't have access or can't ask person who have access to that then what you can do is avoid gson from retrofit.

You can do that using following code:

implementation('com.squareup.retrofit2:retrofit:x.x.x') {

    exclude module: 'gson'
}

You need to review your code thoroughly if applying old version of a library do not causes any issues with Retrofit or your implementation.

Upvotes: 0

panda
panda

Reputation: 466

Maybe you should exclude like below:

compile fileTree(dir: 'libs', excludes: ['gson2.2.4.jar'], include: '*.jar')

Upvotes: 1

Bhoomika Patel
Bhoomika Patel

Reputation: 1925

First delete your gson2.2.4.jar.

If you can't do that then follow this steps.

  1. delete your .gradle and .idea folder from your project directory
  2. Inside your project's app directory delete build directory.
  3. Now delete your gson2.2.4.jar
  4. Then Sync your project
  5. add below dependency for retrofit2
  implementation 'com.squareup.retrofit2:retrofit:2.6.0'
  implementation 'com.squareup.retrofit2:converter-gson:2.6.0'
  implementation 'com.squareup.okhttp3:logging-interceptor:3.12.1'
  implementation 'com.google.code.gson:gson:2.8.5' 

Hope this will helps you.

Upvotes: 0

Related Questions