首页 > 解决方案 > 如何让 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

我能错过什么?

标签: kotlinfuel

解决方案


我通过将依赖项更改为:

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.


推荐阅读