[英]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'
因为JSON序列化和反序列化我正在使用gson-converter库"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 同步之后,我收到了这个错误,无法通过gradle来构建应用程序
Error:Execution failed for task ':app:preMockDebugAndroidTestBuild'. 错误:任务':app:preMockDebugAndroidTestBuild'的执行失败。 Conflict with dependency 'com.google.code.gson:gson' in project ':app'. 在项目':app'中与依赖'com.google.code.gson:gson'冲突。 Resolved versions for app (2.7) and test app (2.8.0) differ. app(2.7)和测试app(2.8.0)的已解决版本有所不同。 See https://d.android.com/r/tools/test-apk-dependency-conflicts.html for details. 有关详细信息,请参阅https://d.android.com/r/tools/test-apk-dependency-conflicts.html 。
I have used retrofit and gson many times in past but never face this sort of error . 我过去曾多次使用过retrofit和gson,但从未遇到过这种错误。 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 . 我最近遇到了改造gson转换工厂的同样问题。 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 . 我做了什么我添加了最新的总gson库作为依赖,就像这个implementation 'com.google.code.gson:gson:2.8.0'
(版本可能不同,这是我写作的时间),突然gradle构建成功。
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 . NB请在投票前添加评论,我明确表示这个对我有用。 Still I have no Idea what was wrong 我仍然不知道出了什么问题
更新版本:
implementation 'com.google.code.gson:gson:2.8.0'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.