問題描述
我正在使用 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 項目?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!