Execution failed for task ':app:kaptDebugKotlin' - Error Occurs while using Hilt

Solution 1:

So, it appears there is an issue integrating Hilt while targeting version 31 (Android 12).

When I had:

compileSdkVersion 31
buildToolsVersion "31.0.0"

defaultConfig {
   minSdkVersion 21
   targetSdkVersion 31
}

The error appears...

but when I changed to:

compileSdkVersion 30
buildToolsVersion "30.0.3"

defaultConfig {
   minSdkVersion 21
   targetSdkVersion 30
}

It starts working, without that error..

Something wrong with integrating Hilt while targeting android 12 (likely)