如何将 Gson 附加功能添加到 Android 项目?

How to add Gson extras to an Android project?(如何将 Gson 附加功能添加到 Android 项目?)
本文介绍了如何将 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) and tried 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.

推荐答案

错误:无法解决:com.google.code.gson:gson-extras:2.8.2

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

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

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

How can I use CClistview in COCOS2d Android?(如何在 COCOS2d Android 中使用 CClistview?)
cocos2d-android: how to display score(cocos2d-android:如何显示分数)
Sqlite database not copied from asset folder Android(Sqlite 数据库未从资产文件夹 Android 复制)
SQLite Database Copy Appears Corrupted When Generated by Device and not Emulator(SQLite 数据库副本在由设备而不是模拟器生成时出现损坏)
Android file copy(安卓文件拷贝)
Android how to detect Copy event of Edittext in android(Android如何在android中检测Edittext的Copy事件)