如何将Gson extras添加到Android项目中?

8

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

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

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

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

然而,这只给我提供了gson库,没有extras(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"

有什么办法让这个工作起来吗?

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

3个回答

10

4
请注意,"包括源代码"是什么意思?这是否意味着我只需将带有许可证标头的代码复制粘贴到文件中并直接使用它,还是有其他含义?提示:包括源代码意味着软件的源代码必须与二进制文件一起提供,以便用户可以查看和修改代码。如果您想直接使用该代码,则需要遵循相应的许可证条件。 - nantitv
有一个第三方发布的Maven包可在https://mvnrepository.com/artifact/org.danilopianini/gson-extras/0.2.1找到。 - Wolfgang Fahl

5

3

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接