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

问题描述 投票:1回答:1

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

我想使用RuntimeTypeAdapterFactory,它是gson extras的一部分。

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

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

但是这只给了我没有额外内容的gson lib(项目中无法识别RuntimeTypeAdapterFactory ...)。

我查看了gson extras的pom文件(https://github.com/google/gson/blob/master/extras/pom.xml),并尝试在我的构建gradle中添加以下行:

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

但gradle只是不会编译gson附加功能:

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

任何想法如何使这项工作?

非常感谢您在这件事上的时间和帮助。

android maven android-gradle build.gradle gson
1个回答
3
投票

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

额外的包未在Maven中发布。

您可以检查以下问题:

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

© www.soinside.com 2019 - 2024. All rights reserved.