A failure occurred while executing org.jetbrains.kotlin.gradle.internal.KaptExecution
Solution 1
Android Studio's UI was just hiding the error...
when the error occurred, it highlighted the item in the list view, and showed an unhelpful message in the terminal view.
to find the real error, select the root item in the list view so that Android Studio would display the whole build output in the terminal view, then scroll to find error.
Solution 2
Maybe I am a bit late for the answer but, anyways, I was getting the same error. The build failure can be caused by some error that Android Studio fails to point out probably due the the project size being very large.
Here is the easy way to point out the exact error.
-
In Android studio go to Analyze menu and click on Inspect Code; check whole project, click OK and wait for the inspection to finish.
-
Now you will see a tab that will point all the errors, warnings etc and you can now resolve the real issue.
Solution 3
The way to find out what the underlying issue is, is to run the following command :
./gradlew assembleDebug --stacktrace
Solution 4
Change
implementation "android.arch.persistence.room:runtime:1.1.1"
kapt "android.arch.persistence.room:compiler:1.1.1"
To (updated 4 - September-2021)
implementation "androidx.room:room-runtime:2.3.0"
annotationProcessor "androidx.room:room-compiler:2.3.0"
Solution 5
I started getting this after upgrading my Android Studio to Arctic Fox(2020.3.1)
.
I resolved it by updating my JDK version from 1.8
to Embedded JDK
.
To change the JDK:
-
Open your project in Android Studio and select File > Settings... > Build, Execution, Deployment > Build Tools > Gradle
-
On Mac: Android Studio > Preferences... > Build, Execution, Deployment > Build Tools > Gradle.
-
Under Gradle JDK, choose the Embedded JDK option.
As mentioned here
Related videos on Youtube

Shubham Tater
Updated on May 13, 2022Comments
-
Shubham Tater 7 months
All of sudden I start getting this error, and I am not getting idea why if anyone just let me know where this error is, will be enough helpful. As much I am able to get is this because of new update of android studio. Detailed summary of error I am getting.
Task :app:kaptDebugKotlin ANTLR Tool version 4.5.3 used for code generation does not match the current runtime version 4.7.1ANTLR Runtime version 4.5.3 used for parser compilation does not match the current runtime version 4.7.1ANTLR Tool version 4.5.3 used for code generation does not match the current runtime version 4.7.1ANTLR Runtime version 4.5.3 used for parser compilation does not match the current runtime version 4.7.1C:\Users\shubh\Downloads\MarginCalculator\app\build\generated\source\kapt\debug\com\kotlin_developer\margincalculator\DataBinderMapperImpl.java:10: error: cannot find symbol import com.kotlin_developer.margincalculator.databinding.FragmentCalculatorScreenBindingImpl; symbol: class FragmentCalculatorScreenBindingImpl Task :app:kaptDebugKotlin FAILED location: package com.kotlin_developer.margincalculator.databinding FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':app:kaptDebugKotlin'. > A failure occurred while executing org.jetbrains.kotlin.gradle.internal.KaptExecution > java.lang.reflect.InvocationTargetException (no error message) * Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights. * Get more help at https://help.gradle.org BUILD FAILED in 17s 29 actionable tasks: 27 executed, 2 up-to-date
-
Sergio over 2 yearsplease show your code in
build.gradle
file. -
Sergio over 2 yearsplease show DataBinderMapperImpl.java code as well.
-
Samuel Eminet over 2 yearsHave you updated to Android Studio 4? same pb here
-
Hani over 2 yearsI updated to Android Studio 4 and I've been getting the same error with using Room, I was able to temporarily fix it by changing one of my queries. I initially had this query: "SELECT case_name FROM SavedCases", and then changed it to "SELECT * FROM SavedCases", and the error message went away. For some reason, I only get this error when I try to query only specific columns. This is not an ideal fix for the problem and I hope someone has a better fix.
-
Mustaqode over 2 yearsI had a similar error and found a solution that works for me. You might have done something similar. stackoverflow.com/questions/63133657/…
-
Dan Alboteanu over 2 yearsfor me it was the primary constructor in one database entry class
-
Nagaraj Alagusundaram over 2 yearsI'm getting this error after migrating to AndroidX
-
Achraf Amil over 2 yearsThere might be many reasons since error message is not explicit. Mine was make an @Inject field private with dagger-hilt.
-
Arbaz.in almost 2 yearsi am facing the same issue for realm any solution ?
-
solidogen 11 monthsMoshi 1.12.0 causes this error with Kotlin 1.6.+ Update moshi to 1.13.0
-
-
Shubham Tater over 2 yearsThis is not the proper solution
-
Mujeeb Rahaman T over 2 years@ShubhamTater This is solution till gradle4.0.0 is to be fixed. This is the temporary solution . Once gradle4.0.0 is fixed . We can update the gradle 4.0 or more
-
Shubham Tater over 2 yearsI got the solution for my problem, I dont know wether it will work for you or not but the soultion is check your XML file which you are binding, binding is a compile time system, and it work for XML file so check it if their is any error in it it will show this type of error. I correct my XML file then everything work perfectly.
-
Shubham Tater over 2 yearsI got the solution for my problem, I dont know wether it will work for you or not but the soultion is check your XML file which you are binding, binding is a compile time system, and it work for XML file so check it if their is any error in it it will show this type of error. I correct my XML file then everything work perfectly.
-
Shubham Tater over 2 yearsRight this error is always related to XML file which our databinding is using.
-
Ярослав Нестеров over 2 yearsI caught this exception on 4.0.1
-
Mustaqode over 2 yearsWhat kind of mistakes?
-
Bolt UIX over 2 yearsyes, it is showing exactly error. (i made some mistake in XML)
-
Simo Nyathi over 2 yearsYes please. how did you dig deeper?
-
Ally over 2 years@LeonardoSibela sorry for that, what I meant to say is adding the --stacktrace option when building so I can get more information on the error.
-
moyo over 2 yearsI don't understand why Android Studio does not show the error directly when a build fails, it makes no sense. Thanks for this, helped me a lot
-
Amber over 2 yearsYou can add the --stacktrace option from File->Settings->Build,Execution,Deployment->Compiler->Command-line Options Btw in my case I was missing a dependency: implementation "androidx.room:room-ktx:$room_version"
-
Idan Damri about 2 yearsif you have a compile-time Room (DB) error it will show it like that - that means that one or some of your queries is wrong
-
Ishaan Kumar about 2 yearsIn my case, I forgot to add
@Dao
in MyDao interface -
user25 about 2 yearsamazing, it's helped
-
user25 about 2 years
gradle->app->Tasks->Build->assemble
what is that? -
Ajay J G about 2 years@user25 Gradle tool window
-
Eric about 2 yearsI guess it will show like this for any compile-time DB error...in my case, it was a compile-time Realm DB error about a wrongly set up entity object...
-
Daniel Wilson about 2 yearsJudging by the upvotes, the UI decision here is not a good one
-
Mark Lapasa about 2 yearsthx for this. I switched it to use 'annotationProcessor' and it successfully built. Then I switched it back to 'kapt' and it was able to build again.
-
varotariya vajsi about 2 yearsin my case i have forgot to give @PrimaryKey to one of my class
-
Arbaz.in almost 2 yearsWhat about the realm, i don't know why after updating realm dependency i was getting errors Execution failed for task ':app:kaptJambodevDebugKotlin'. like this ,any solution for same?
-
gMale almost 2 yearsNote that the error info will not be in the stacktrace. Instead, when you add the
--stacktrace
flag the error info shows up right aboveFAILURE: Build completed with N failures.
It took me a second to realize that the room messages were there. -
BrandonRG almost 2 yearsThank you so mucho bro. This help me.
-
Ajay J G almost 2 yearsAssemble will build your artifacts, in other words, assembles the outputs of the project but doesn't build. Build = Assemble + check.
-
Deepak Borade almost 2 yearsgreat bro.you save my time
-
nyxee over 1 yearThis worked for me. It is never mentioned in the Documentation. So, the set() and notifyPropertyChanged() methods are no longer required??
-
Arst over 1 yearThank you! Very helpful.
-
Sunkas over 1 yearOnly useful answer here as problem can vary!
-
Lilia over 1 yearwith
annotationProcessor
, the error was pretty clear. Thank you -
Lilia over 1 yearIf you don't see any explanation in that part, you should change the gradle implementation to:
implementation "androidx.room:room-runtime:$room" implementation "androidx.room:room-ktx:$room" kapt "androidx.room:room-compiler:$room" androidTestImplementation "androidx.room:room-testing:$room"
-
Mahmoud Mabrok over 1 yearI am using same version, and with new update it does not work anymore.
-
Slion over 1 yearI still don't get it…
-
Naimul Kabir over 1 yearThanks a lot, man. I was facing the issue, as I didn't add @Dao annotation in my Dao abstract class.
-
Elliot Schrock over 1 yearHad this problem on an old project after updating to AS v4.1.1 and gradle 6.5 (I believe that's the gradle version). Following this answer and updating room deps from 1.0.0 to 2.3.0 worked for me.
-
Waqas ali over 1 yearBravo! totally save the day
-
Ahmad Salman over 1 yearThe best answer to the question is this one. there is no one answer to the question a lot could happen so inspect code is the best solution so far.
-
Sathish over 1 yearBeing all setup and annotations correctly i.e Room setup and annotations still faced this issue kaptExecution failure. This solution save me!
-
Edgar over 1 yearI am getting the same error what is your suggestion
-
Qadir Hussain about 1 year@NaimulKabir thanks. I was missing that too damn Dao. wasted almost 2 hours
-
Peter Nied about 1 yearThis does not really answer the question. If you have a different question, you can ask it by clicking Ask Question. To get notified when this question gets new answers, you can follow this question. Once you have enough reputation, you can also add a bounty to draw more attention to this question. - From Review
-
fabio.sang about 1 yearIn my case, I had a @TypeConverter from Long to Date but I eliminated the one from Date to Long
-
Nicolas Mage about 1 yearThanks. good workaround to get some funky versions to play nice together.
-
Atif AbbAsi about 1 yearthanks, it worked for me. but now getting the default launcher class does not exist.
-
Kishan Solanki about 1 yearOk. Then what's the solution?
-
Pradeep Singh about 1 yearThis worked for me ./gradlew clean assembleDebug --stacktrace
-
Yasir Ali about 1 yearafter an hour my project working with this fix. thanks
-
Ajay P. Prajapati about 1 yearThis isn't the correct answer because you must use
kapt
now. What solved problem for me is to update android studio gradle build tools and gradle version. It fixed the issue for me and keptkapt
-
Chris Nevill about 1 yearThis gives me the warning : app: 'annotationProcessor' dependencies won't be recognized as kapt annotation processors. Please change the configuration name to 'kapt' for these artifacts: 'androidx.room:room-compiler:2.3.0'. WARNING: The specified Android SDK Bu
-
Chris Nevill about 1 yearI think if you look here you still need the kapt - or possibly now alternatively the ksp line: developer.android.com/training/data-storage/room#kts
-
Trevor Gowing 12 monthsAdding
--stacktrace
to my Gradle command did the trick. Thanks, @Etienne. -
shubham chouhan 11 monthsGave me direction, thanks, just updating room version to 2.4.0-alpha03 worked for me
-
MatJB 11 monthsNot exactly the same error, but this solved my problem after adding Hilt to my project. The error I had was: A failure occurred while executing org.jetbrains.kotlin.gradle.internal.KaptWithoutKotlincTask$KaptExecutionWorkAction > java.lang.reflect.InvocationTargetException (no error message)
-
Hashir Ali 11 monthsThis resolved my issue!
-
btraas 11 monthsThank you. Downgrading to 2.3 made it work for now...
-
Ali Salehi 10 monthsfinally after a week, I found the solution! thanks man
-
Adnan Bal 10 monthsFor Apple M1 users : This solution is for you!.
-
antaki93 9 monthsCan you explain in detail, please?
-
Adrian Sicaru 9 monthsI know I am a bit late to the party, but I have a similar problem. And I don't know how to switch to annotationProcessor from kapt.
-
Kyriakos Georgiopoulos 9 monthsAt least you will find out what is the error with the DI
-
Mahmoud Mabrok 8 monthsfor new ones. @AjayJG was meant at gradle side menu form IDE open app then tasks
-
mustafa hasria 7 monthsThe solution for the M1 chip worked perfectly with me too Thanks