Search code examples
kotlinfuel

How to make Kotlin Fuel json serializer to compile?


I'm trying to use Fuel JSON deserializer so I added it to my dependencies like this:

implementation 'com.github.kittinunf.fuel:fuel:2.2.1'
implementation 'com.github.kittinunf.fuel:fuel-json:2.2.1'

However each time I'm running ./gradlew clean build I'm getting this error:

> Task :compileKotlin FAILED
e: /DirToMyClass/MyClass.kt: (55, 26): Cannot access class 'org.json.JSONObject'. Check your module classpath for missing or conflicting dependencies

I've run ./gradlew dependencies to check that there are no other dependency importing org.json and the only one is 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

What can I be missing?


Solution

  • I've fixed this by changing the dependencies to:

    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'
    

    Using a newer version of org.json:json.