Gradle DSL method not found: 'kapt()'

AndroidGradleKapt

Android Problem Overview


Gradle DSL method not found: 'kapt()' Possible causes: The project 'jetpacklearn' may be using a version of the Android Gradle plug-in that does not contain the method (e.g. 'testCompile' was added in 1.1.0). Upgrade plugin to version 3.4.0 and sync project

The project 'jetpacklearn' may be using a version of Gradle that does not contain the method. Open Gradle wrapper file

My gradleVersion is '3.4.0', but can not deal with it , ask me the same question

    classpath "com.android.tools.build:gradle:$gradleVersion"
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
    classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$navigationVersion"

Android Solutions


Solution 1 - Android

Check if you have this in top of your app build.gradle?

apply plugin: 'kotlin-kapt'

Solution 2 - Android

add this line

apply plugin: 'kotlin-kapt'

if you used kapt in android library you must add kotlin-android plugin in your project

apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'

Solution 3 - Android

just add this line in your app-level of build.grale :

apply plugin: 'kotlin-kapt'

NOTE: under apply plugin: 'com.android.application'

Solution 4 - Android

Add this in your build.gradle then sync the gradle again.

> apply plugin: 'kotlin-kapt'

Solution 5 - Android

Your build.Gradle file should have these at the top

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'

Solution 6 - Android

apply the below plugin in your app-level build.gradle.

apply plugin: 'kotlin-kapt'

Solution 7 - Android

The answer https://stackoverflow.com/a/56101024/6007104 is absolutely correct.

But, for people using the gradle plugins block, it looks like this:

plugins {
    id('kotlin-kapt')
}

Solution 8 - Android

This is because you are missing apply 'kotlin-kapt' in app level gradle. There is two ways to add this plugin.

if your project having plugin block. please add like below.

plugins {
    ...
    ...
    id 'kotlin-kapt'
}

or you can add by using apply key word.

apply plugin: 'kotlin-kapt'

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questioncheng zhangView Question on Stackoverflow
Solution 1 - AndroidIgnacio Tomas CrespoView Answer on Stackoverflow
Solution 2 - AndroidKouroshView Answer on Stackoverflow
Solution 3 - AndroidSana EbadiView Answer on Stackoverflow
Solution 4 - AndroidtonnyView Answer on Stackoverflow
Solution 5 - AndroidC WilliamsView Answer on Stackoverflow
Solution 6 - Androiddev_mg99View Answer on Stackoverflow
Solution 7 - AndroidLukeView Answer on Stackoverflow
Solution 8 - AndroidMelbin K JosephView Answer on Stackoverflow