Unable to find Gradle tasks to build error


I'm trying to run main function of a kotlin file. I can build it, jar it, but i can't run it using the green arrow button and i've this message I've tried Invalidating caches, restarting my computer but nothing can make this work, is there a way to fix it ?


Please open the Gradle tool window in the right sidebar, and click the refresh button in the toolbar.
Can the IDE reload your project without any problems?
Also, try checking if the green button works after reloading this project successfully.

IDE reloading project without any problems, but still not working after that.

Would it be possible to share a sample of this project for investigating?
You could upload this project to https://uploads.jetbrains.com/ and share us the upload id?

I had the same problem when using latest/stable (2023.1) after I downgraded it to 2022.3/stable (2022.3.3) this problem went away and I can again run things using the green arrow.

Sadly, I still fail to reproduce this issue and I think it should be specific to some project configuration.
It would help us a lot to find the root cause if someone can share a sample project for reproducing this issue. (You could remove any sensitive code in it and recreate a similar project from the affected one with no sensitive info)
Thanks a lot!

Sorry, i was unavailable lately,

I don't know how, but the problem resolved itself, one day I logged in and the project started as usual, and I could run the project perfectly.


Lejia Chen

I've been running into this issue too and was able to reproduce the issue in an example project. Upload id: 2023_04_30_25JWHdoC8rd5XBEpPZYYi6 (file: compile_java_issue.zip)

Was seeing the issue in both (2023.1) and (2023.1.1). I downloaded (2022.3.3) to see if this downgrade helped me but started to run into other issues.


I just ran my test repo app that I just uploaded with (2022.3.3) with a downgrade to AGP and it looks like the app does run ok.


Somehow when I went to work on my project this morning I got "task 'compileJava' not found in project" error in a different submodule when I went to build it, and this is using (2022.3.3).

My submodule/subproject builds ok with (2023.1.x) and a certain version of AGP but the original project I was working on only builds and runs on (2022.3.3) with another version of AGP. Can't seem to win.

I wish AGP and Intellij compatibility would get more stable. Been dealing with compat issues for way too long.


Thanks for the example. I have created a bug report here: https://youtrack.jetbrains.com/issue/IDEA-319618/Unable-to-find-Gradle-tasks-to-build-xxx-Build-mode-COMPILEJAVA-when-running-a-Kotlin-file-in-a-project-using-compose
Please vote for it for updates.

From my testing, the bundled Android plugin is related to this issue. If I disable it, I can run this project without any problems.
You may use the Grable command to run/build the project currently as a workaround.

What works for me is : 

  1. delete folders [build, .idea, .gradle]
  2. resync or Invalidate Caches / Restart

Hope it helps..