search

Home  >  Q&A  >  body text

android - Gson库的引用

项目中用到了retrofit网路请求框架,然后json解析系添加了
compile 'com.squareup.retrofit2:converter-gson:2.1.0'
感觉已经够用了,但是为什么看到有的项目中还要添加gosn库
compile 'com.google.code.gson:gson:2.6.2'

黄舟黄舟2772 days ago494

reply all(4)I'll reply

  • 高洛峰

    高洛峰2017-04-17 17:34:14

    The one above is a package repackaged by retrofit itself, while the bottom one is Google’s official GSON package. A situation often occurs where retrofit is used, and then some third-party projects are used that rely on official Gson development projects, and then there is no All methods can only be used. This is a problem that often occurs when using third-party open source projects.

    reply
    0
  • PHP中文网

    PHP中文网2017-04-17 17:34:14

    You should just pass the code that references converter-gson:2.1.0'. It may be that the compilation tool defaults to using Google's gson package after seeing gson.

    reply
    0
  • PHP中文网

    PHP中文网2017-04-17 17:34:14

    Default relies on gson and uses gson to parse json. You no longer need to reference the gson library separately

    reply
    0
  • 迷茫

    迷茫2017-04-17 17:34:14

    1. The dependency of converter-gson is transparently transmitted, so that the dependency of gson is automatically added.
    2. You can use @aar to turn off transparent transmission

    reply
    0
  • Cancelreply