简体   繁体   中英

Conflict with dependency 'com.google.code.gson:gson' in project ':app'. Resolved versions for app (2.7) and test app (2.8.0) differ

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

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

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

更新版本:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM