Could not find method kapt() for Glide
Asked Answered
K

4

27
apply plugin: 'com.google.gms.google-services'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'

classpath 'com.android.tools.build:gradle:3.2.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.61"

I have the above gradle configuration, and still I am getting

Could not find method kapt() for arguments [com.github.bumptech.glide:compiler:4.3.1] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

Can someone tell me where am I going wrong? Thanks for the help in advance

Kaykaya answered 30/9, 2018 at 17:53 Comment(0)
H
59

The project-level build.gradle:

buildscript {
    repositories {
        mavenCentral()
        jcenter()
        google()
    }
    dependencies {
        classpath "com.android.tools.build:gradle:3.3.2"
        classpath "com.google.gms:google-services:4.2.0"
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.70"
    }
}

The module-level build.gradle:

apply plugin: "kotlin-android"
apply plugin: "kotlin-android-extensions"
apply plugin: "kotlin-kapt"
...
android {

} 
dependencies {
    implementation "com.github.bumptech.glide:glide:4.8.0"
    // annotationProcessor "com.github.bumptech.glide:compiler:4.8.0"
    kapt "com.github.bumptech.glide:compiler:4.8.0"
}
...
apply plugin: "com.google.gms.google-services"
Hoptoad answered 1/10, 2018 at 4:48 Comment(0)
S
10
plugins {
    id 'com.android.application'
    id 'kotlin-android'
    id 'kotlin-android-extensions'
    id 'kotlin-kapt' // add this line in file build.gradle (Module : YourAppName)
}
Sitology answered 23/11, 2020 at 13:32 Comment(0)
C
0

Apply must be under plugins this worked for me

plugins {
    id 'com.android.application'
    id 'kotlin-android'
}
apply plugin: "kotlin-android-extensions"
apply plugin: 'kotlin-kapt'

And in the other build.grandle:

buildscript {
    ext.kotlin_version="1.4.0"
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:7.0.1'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}
Cockney answered 31/8, 2021 at 14:46 Comment(0)
C
-3

I think kapt is available with the new versions of Glide so, try adding:

kapt 'com.github.bumptech.glide:compiler:4.8.0'

In your Build.gradle dependencies when using Kotlin.

Note that the Glide dependency should have the same version as the compiler :

dependencies {
    implementation 'com.github.bumptech.glide:glide:4.8.0'
    kapt 'com.github.bumptech.glide:compiler:4.8.0'
}

Or, try updating your Kotlin to v1.2.71:

buildscript {

    ext.kotlin_version = '1.2.71'
}


 dependencies {
        classpath 'com.android.tools.build:gradle:3.2.0'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}

In the root Build.gradle. This should work.

Cistercian answered 30/9, 2018 at 17:55 Comment(2)
tried with Glide 4.8.0 as well getting the same error.Kaykaya
Try updating your kotlin to v1.2.71 and then see what happens? Check my updated answer.Mind

© 2022 - 2024 — McMap. All rights reserved.