kotlin only id(String), alias(Provider), or alias(ProviderConvertible) method calls allowed in plugins {} script block

Error while building the Android project using Hilt.

Issue: You must have added kotlin(“kapt”) in the build.gradle like this:

plugins {
    id 'com.android.application'
    id 'org.jetbrains.kotlin.android'
    kotlin("kapt")
    id("com.google.dagger.hilt.android")
}

The solution is to add it like this:

plugins <strong>{
    </strong>id 'com.android.application'
    id 'org.jetbrains.kotlin.android'
    id 'kotlin-kapt'
    id("com.google.dagger.hilt.android")
<strong>}</strong>

you need to replace kotlin(“kapt”) with id ‘kotlin-kapt’ and the issue will be fixed.