How to add Gson extras to an Android project?(如何将 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 项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何将 Gson 附加功能添加到 Android 项目?


- 使用自定义动画时在 iOS9 上忽略 edgesForExtendedLayout 2022-01-01
- 想使用ViewPager,无法识别android.support.*? 2022-01-01
- MalformedJsonException:在第1行第1列路径中使用JsonReader.setLenient(True)接受格式错误的JSON 2022-01-01
- 如何检查发送到 Android 应用程序的 Firebase 消息的传递状态? 2022-01-01
- 在测试浓缩咖啡时,Android设备不会在屏幕上启动活动 2022-01-01
- Android - 拆分 Drawable 2022-01-01
- 用 Swift 实现 UITextFieldDelegate 2022-01-01
- Android - 我如何找出用户有多少未读电子邮件? 2022-01-01
- android 4中的android RadioButton问题 2022-01-01
- Android viewpager检测滑动超出范围 2022-01-01