4
votes

I am facing a very weird problem . In my project I am retrofit as a network library . SO for JSON serialisation and deserialisation I am using gson-converter library "com.squareup.retrofit2:converter-gson:$rootProject.retrofitVersion" // rootProject.retrofitVersion = '2.3.0'

after sync I got this error which failed gradle to build the app

Error:Execution failed for task ':app:preMockDebugAndroidTestBuild'. Conflict with dependency 'com.google.code.gson:gson' in project ':app'. Resolved versions for app (2.7) and test app (2.8.0) differ. See https://d.android.com/r/tools/test-apk-dependency-conflicts.html for details.

I have used retrofit and gson many times in past but never face this sort of error . Please some one help me . I have searched a lot , non of the solution works

2

2 Answers

17
votes

I have recently faced this same issue with retrofit gson convert factory . see this issue . I didn't get the solution yet though . I have searched a lot just like you . Luckily I have applied a ghostbuster solution , I repeat this is a ghostbuster solution . I have no acceptable explanation for this .

what I did I add latest total gson library as a dependency like this implementation 'com.google.code.gson:gson:2.8.0' (version may differ this one was the time of my writing) and suddenly gradle build was successful .

please let me know if it works for you too

N.B please before down voting add a comment , I made myself clear this one works for me . Still I have no Idea what was wrong

1
votes

update version with:

implementation 'com.google.code.gson:gson:2.8.0'