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

问题描述

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

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

我想使用 RuntimeTypeAdapterFactory 这是 gson extras 的一部分.

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 库没有额外的(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 附加功能:

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 中发布.

您可以检查这些问题:

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

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 附加功能添加到 Android 项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-19 05:23