Execution failed for task ':app:compileDebugKotlin'

I solved this problem by building the project in terminal then run app in intellij(or android studio).

gradle clean build -> run app in ide


For me, the solution was to open the Gradle Console window in Android Studio and run the build with a StackTrace.

Then, reading through that, I realised that the new of doing some things in Kotlin required my code to change, but a normal Gradle build didn't catch those problems.

It was things like views being cast to TextView or whatever the case might be, that was not relevant anymore, and had to be changed to the findVieById format. e.g.:

val textView = snackbarView.findViewById(R.id.snackbar_text) as TextView

had to be changed to

val textView = snackbarView.findViewById<TextView>(R.id.snackbar_text) 

Tags:

Android