我正在尝试遵循有关 Android 应用程序的教程。我正在使用依赖项 Fuel (它依赖于 com.google.Gson 反序列化器)。但Gson()不是由IDE导入的。
我尝试指定较低版本的 gson。我已经重新同步了所有项目的 gradle。我尝试手动编写导入(import com.google.gson.Gson),但我无法使用 Gson() 构造函数。我已经阅读了有关使用 Gson 的手册,但似乎没有任何改变。总是一样的。调用构造函数 Gson() ,毕竟静态方法... Gson().fromJson(....)
这是我的 build.gradle 中的部分(模块:应用程序)
// Fuel HTTP Client
implementation 'com.github.kittinunf.fuel:fuel:2.2.0'
implementation 'com.github.kittinunf.fuel:fuel-android:2.2.0'
implementation 'com.github.kittinunf.fuel:fuel-gson:2.2.0'
Run Code Online (Sandbox Code Playgroud)
在代码中,我在 ArticleDataProvider.kt 中使用:
class WikipediaDataDeserializer : ResponseDeserializable<WikiResults> {
override fun deserialize(reader: Reader): WikiResults? {
return Gson().fromJson(reader, WikiResults::class.java)
}
}
Run Code Online (Sandbox Code Playgroud)
通常,我希望 IDE 能够识别 Gson(),这样我就能够正常调用 .fromJson() 。Gradle 已正确下载。(我没有任何消息错误)。
这个问题可能会被问很多次,但仍然不是所有的答案都能得到解决。因为我只剩下不到 20 小时了所以我希望有人能给我一些建议。真的很感谢你的帮助。
目前,我只剩下一个测试用例失败要处理(测试用例 3),但我不知道我忘记包括什么情况。我为我制作了一个 Matrix 和 Fraction 类,以便更轻松地进行操作。对不起,注释 println 是为了我的调试。
我使用吸收马尔可夫链的概念来找到 Q、R、F 和 FR 矩阵,这些矩阵启发了我https://github.com/ivanseed/google-foobar-help/blob/master/challenges/doomsday_fuel/doomsday_fuel.md。
如果您有任何意见,再次感谢!请帮忙!
问题和我的 Solution.java 如下:
题:
Write a function solution(m) that takes an array of array of nonnegative ints representing how many times that state has gone to the next state and return an array of ints for each terminal state giving the exact probabilities of each terminal state, represented as the numerator for each state, then the denominator for all of them …Run Code Online (Sandbox Code Playgroud)