简体   繁体   中英

Kotlin IntelliJ IDEA update - Top-Level function 'main()' not found in package

I have a project, only one among others, that always loses its 'main()' after updates.

The Run config says: "Warning: Class 'MainKt' has no 'main()' method, even the Main.kt file contains a fun main() {}. Note the 'main' is not highlighted like in a healthy project.

I tried to remove the Main.kt and create an other one. Same issue.

I tried to check .idea/* files and compare with healthy projects. Didn't found something different. But maybe I hadn't not well seen.

I had to recreate my project from crash 3 times.

Any idea? (pun not intended)

The solution was to change the minimal...

fun main() {...}

by:

fun main(args: Array<String>) { }

From there, the main(...) function backed to be visible for IntelliJ

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM