kotlin - 如何让 Kotlin Fuel json 序列化器编译?
问题描述
我正在尝试使用Fuel JSON 反序列化器,所以我将它添加到我的依赖项中,如下所示:
implementation 'com.github.kittinunf.fuel:fuel:2.2.1'
implementation 'com.github.kittinunf.fuel:fuel-json:2.2.1'
但是,每次我运行时./gradlew clean build
,我都会收到此错误:
> Task :compileKotlin FAILED
e: /DirToMyClass/MyClass.kt: (55, 26): Cannot access class 'org.json.JSONObject'. Check your module classpath for missing or conflicting dependencies
我跑去./gradlew dependencies
检查没有其他依赖项导入org.json
,唯一的一个是fuel-json
.
+--- com.github.kittinunf.fuel:fuel-json:2.2.1
| +--- com.github.kittinunf.fuel:fuel:2.2.1 (*)
| +--- org.jetbrains.kotlin:kotlin-stdlib:1.3.50 -> 1.3.60 (*)
| \--- org.json:json:20180813
我能错过什么?
解决方案
我通过将依赖项更改为:
implementation 'com.github.kittinunf.fuel:fuel:2.2.1'
implementation('com.github.kittinunf.fuel:fuel-json:2.2.1') {
exclude group: 'org.json', module: 'json'
}
implementation 'org.json:json:20190722'
使用较新版本的org.json:json
.
推荐阅读
- tensorflow - “pip install models”:命令出错,退出状态为 1:python setup.py egg_info 检查日志以获取完整的命令输出
- android - 逐项滚动卡片列表
- python - 训练测试拆分后丢弃值
- highcharts - 在 X 轴下显示信息,例如在 Excel 中使用 Highcharts
- sql - MS ACESS 按多个标准对列进行排名
- c - 在 C 中查找素数
- python - 如何使用列表理解遍历对象属性?
- vhdl - 用于读取十六进制并转换为 std_logic_vector 的 Vhdl 代码
- openshift - 部署“分蘖”超过了进度期限
- node.js - 将 jest 与 mongoose 一起使用时,“ReferenceError: You are trying to `import` a file after Jest environment has been torn down”