Android Studio cannot open Android project with Kotlin DSL

I was able to 'fix' it by deleting the .idea directory and reopening the project. The .idea directory is usually not committed in git but I guess copying the directory invalidates the directory structures in the files within the .idea directory.

The whole bug is easily reproducible when you click on File > Re-import Gradle project.


@Boni2k answer does not work for me.

I have to rename the root build.gradle.kts back to build.gradle, fix the syntax error, sync the project (which works fine immediately), and rename the file back to build.gradle.kts. Then the error is gone and I can sync the project successfully.

What I did to raise the error was that I moved the project to a different folder, and rename the project.