Error:Execution failed for task ‘:app:compileDebugKotlin’. > Compilation error. See log for more details

I got such error after a simple try of code refactoring. It has happened nor after some library was connected neither any changes in gradle. It looked like something in my code was wrong but the compiler could not found the issue. That’s why I double checked all changes that I did and found that I had changed somehow method signature in the interface but had not changed it in class that implements it.
I got this error twice during one day and decided to share my experience. I hope that it is a temporary compiler bug.

Solution 1 Possible solution is to go to File -> Settings -> Compiler -> and add “–stacktrace –debug” to Command-line Options. Read log and try to found the answer of what went wrong.

In new Android Studio 3.1.+, you can enable/disable console log details by pressing “Toggle View” on “Build” tab. There you can find the details. Pay attention that both modes can be useful for investigation of the problem’s reason. See: https://stackoverflow.com/a/49717363/

enter image description here

Solution 2 Click on Gradle (on the right side bar) then under :app choose assembleDebug (or assembleYourFlavor if you use flavors). Error will show up in Run tab. See: https://stackoverflow.com/a/51022296

Solution 3 As a last resort. In the android studio, try Analyze -> Inspect Code -> Whole project. Wait until the inspection is over and then correct errors in “General” section and possible ones in other sections.

Note The kapt3 can be a source of such bugs. I removed apply plugin: 'kotlin-kapt' and added kapt { generateStubs = true } into android {} section of build.gradle. It seems that the previous version of the kapt generator is bugs free. (Update. It looks like a bug with kapt is gone on kotlin version 1.2.+)

Leave a Comment