loloof64
06/05/2024, 4:02 PMSam
06/05/2024, 4:03 PMrunBlocking
function is using the last line of its code block as its return value, which in this case is a Job
. The main()
function needs to return Unit
!Joffrey
06/05/2024, 4:03 PMfun main() = runBlocking { ... }
, the return type of main is inferred to be whatever runBlocking
returns. You can use an explicit Unit
instead, or use a block body instead of an expression body.ephemient
06/05/2024, 4:04 PMfun main(): Unit = runBlocking { ... }
or
fun main() {
runBlocking { ... }
}
or
fun main() = runBlocking<Unit> { ... }
loloof64
06/05/2024, 4:05 PMephemient
06/05/2024, 4:05 PMsuspend fun main(): Unit {
...
}
the Kotlin compiler will put in a simple event loop to bridge to Java-like main
Joffrey
06/05/2024, 4:06 PMNo main method found in project
really means that Kotlin didn't find a method that matches the expected signature of a main
method. Even though you do have a main()
function, it doesn't conform to the expected signature of a main function (which required returning Unit
)loloof64
06/05/2024, 4:07 PMJoffrey
06/05/2024, 4:09 PMloloof64
06/05/2024, 4:10 PMJoffrey
06/05/2024, 4:11 PMloloof64
06/05/2024, 4:11 PMJoffrey
06/05/2024, 4:12 PMloloof64
06/05/2024, 4:13 PMloloof64
06/05/2024, 4:17 PMJoffrey
06/05/2024, 4:19 PMloloof64
06/05/2024, 4:20 PMloloof64
06/05/2024, 4:20 PMloloof64
06/05/2024, 4:28 PM