本文介绍了如何将Gson Extras添加到Android项目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用gson解析器(最新版本-> 2.8.2).

I am using gson parser (latest version -> 2.8.2).

我想使用 RuntimeTypeAdapterFactory ,它是gson附加功能的一部分.

I would like to use RuntimeTypeAdapterFactory which is part of the gson extras.

在我的build.gradle中,目前只有一个编译指令:

In my build.gradle there is currently a single compile directive:

compile 'com.google.code.gson:gson:2.8.2'

但是,这仅给了我gson lib而没有其他功能(在项目中无法识别RuntimeTypeAdapterFactory ...).

However this gives me only the gson lib without the extras (RuntimeTypeAdapterFactory is not recognized in the project...).

我查看了gson extras的pom文件( https://github.com/google/gson/blob/master/extras/pom.xml )和试图将以下行添加到我的构建gradle:

I have looked at gson extras' pom file (https://github.com/google/gson/blob/master/extras/pom.xml) andtried to add below line to my build gradle:

compile 'com.google.code.gson:gson-extras:2.8.2'

但是gradle不会编译gson Extras:

But gradle just won't compile the gson extras:

"Error:Failed to resolve: com.google.code.gson:gson-extras:2.8.2"

任何想法如何使这项工作有效吗?

Any Idea how to make this work?

非常感谢您的时间和协助.

Thank you very much for your time and assistance in this matter.

推荐答案

多余的软件包未在Maven中发布.

您可以检查以下问题:

  • https://github.com/google/gson/issues/1104
  • https://github.com/google/gson/issues/1123

如您所见,此包尚未发布,使用内部类的最佳方法就是在项目中包含源代码.

As you can read this package is not published and the best way to use the classes inside is just to include source-code in your project.

这篇关于如何将Gson Extras添加到Android项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-25 11:29