In Android Studio I've created a dummy project to testing package Klaxon, that handles JSON. So I put the below code inside onCreate do change the text of creatorButton button.
class Product(val name: String) // Kotlin, but could be Java
val product = Product("HDD")
val result = Klaxon().toJsonString(product)
creatorButton.text = result
Klaxon is in jcenter repository. So in Build.Gradle module file, I've added in dependency group:
implementation 'com.beust:klaxon:5.0.1'
When I've run the app in my Android cell phone, the button display the label
{"Name":"HDD"}
After, I want to test Klaxon in depth on IntelliJ IDEA so I don't need emulate or run in cell phone all the times that I want to test something.
So I've created a empty Kotlin project with Gradle.
fun main() {
class Product(val name: String)
val product = Product("HDD")
val result = Klaxon().toJsonString(product) // Error
println(result)
}
I follow the tips in this question and add the JAR library in Project Structure (It doesn't work) or add the JAR library in libs folder and run "Add as Library"(it did not work either)
PS: I've tried to edit the dependencies in Gradle.build, but it not accept the same Android Studio syntax.
How can I do to solve this mistery?
No matter what I do, it always gives error on the line with Klaxon call()