Dvir Barzilay
Dvir Barzilay

Reputation: 87

Gradle DSL method not found: 'kapt()' and Plugin with id 'kotlin-kapt' not found

I develop an Android app with a search interface using Algolia.

For this purpose, I follow this guide for InstantSearch but when I add the kapt "androidx.lifecycle:lifecycle-compiler:2.0.0" dependency to my app build.gradle I got ERROR: Gradle DSL method not found: 'kapt()' error.

I tried to add apply plugin: 'kotlin-kapt' in the top of the app build.gradle file (see this) but then I got Plugin with id 'kotlin-kapt' not found. error.

Here is my app build.gradle file:

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

android {
    buildToolsVersion "28.0.3"
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.memoryDiary.Activity.Start"
        minSdkVersion 21
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    //noinspection GradleCompatible
    implementation 'androidx.appcompat:appcompat:1.0.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'com.google.android.material:material:1.0.0'
    implementation 'androidx.cardview:cardview:1.0.0'
    implementation 'androidx.recyclerview:recyclerview:1.0.0'
    implementation 'com.sangcomz:FishBun:0.9.1'
    implementation 'com.squareup.picasso:picasso:2.71828'
    implementation 'com.getbase:floatingactionbutton:1.10.1'
    implementation 'com.github.clans:fab:1.6.4'
    implementation 'com.github.bumptech.glide:glide:4.9.0'
    implementation 'com.mobsandgeeks:android-saripaar:2.0.3'
    implementation 'androidx.legacy:legacy-support-v13:1.0.0'

    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.1.0'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'

    implementation 'com.google.firebase:firebase-auth:17.0.0'
    implementation 'com.google.firebase:firebase-database:17.0.0'
    implementation 'com.google.firebase:firebase-core:16.0.9'
    implementation 'com.google.firebase:firebase-storage:17.0.0'
    implementation 'com.google.firebase:firebase-ml-vision:22.0.0'
    implementation 'com.google.firebase:firebase-ml-vision-image-label-model:18.0.0'

    implementation 'com.algolia:algoliasearch-android:3.+'
    implementation 'com.algolia:instantsearch-android:2.0.0'
    implementation "androidx.lifecycle:lifecycle-extensions:2.0.0"
    kapt "androidx.lifecycle:lifecycle-compiler:2.0.0"

    implementation 'com.google.code.gson:gson:2.8.5'
}

How can I solve this problem?

Upvotes: 4

Views: 4495

Answers (2)

Asad
Asad

Reputation: 283

if you use kotlin, you must use this:

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

Upvotes: 1

barq
barq

Reputation: 3711

You need to apply the following plugin as well:

apply plugin: 'kotlin-android'

Upvotes: 1

Related Questions