Android 2 files found with path 'META-INF/gradle/incremental.annotation.processors'. error
Asked Answered
A

4

11

I'm building an app with Room, Retrofit and Hilt. When I run the app I get an error 2 files found with path 'META-INF/gradle/incremental.annotation.processors'. I've tried to clean and rebuild project but it didn't help. What can I do to solve the issue?

Gradle:

plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
id 'kotlin-kapt'
id 'com.google.dagger.hilt.android'

}

android { namespace 'com.example.gymencv2' compileSdk 33

defaultConfig {
    applicationId "com.example.gymencv2"
    minSdk 21
    targetSdk 33
    versionCode 1
    versionName "1.0"

    testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    vectorDrawables {
        useSupportLibrary true
    }
}

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
    }
}
compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
    jvmTarget = '1.8'
}
buildFeatures {
    compose true
}
composeOptions {
    kotlinCompilerExtensionVersion '1.3.2'
}
packagingOptions {
    resources {
        excludes += ('/META-INF/{AL2.0,LGPL2.1}')
    }
}

}

dependencies {

implementation 'androidx.core:core-ktx:1.9.0'
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.5.1'
implementation 'androidx.activity:activity-compose:1.6.1'
implementation "androidx.compose.ui:ui:$compose_ui_version"
implementation "androidx.compose.ui:ui-tooling-preview:$compose_ui_version"
implementation 'androidx.compose.material:material:1.3.1'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.4'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.0'
androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_ui_version"
debugImplementation "androidx.compose.ui:ui-tooling:$compose_ui_version"
debugImplementation "androidx.compose.ui:ui-test-manifest:$compose_ui_version"

//Retrofit
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
implementation "com.squareup.okhttp3:okhttp:5.0.0-alpha.2"
implementation 'com.squareup.okhttp3:logging-interceptor:4.8.1'

//Navigation component
implementation "androidx.navigation:navigation-compose:$nav_version"

//Coil
implementation("io.coil-kt:coil-compose:2.2.2")
implementation("io.coil-kt:coil-svg:2.2.2")

//Room
implementation "androidx.room:room-runtime:$room_version"
annotationProcessor "androidx.room:room-compiler:$room_version"
kapt "androidx.room:room-compiler:$room_version"
implementation("androidx.room:room-ktx:$room_version")

//Dagger-Hilt
implementation "com.google.dagger:hilt-android-compiler:$hilt_version"
kapt "com.google.dagger:hilt-android-compiler:$hilt_version"
implementation "com.google.dagger:hilt-android:$hilt_version"

},

    ext {
        compose_ui_version = '1.3.2'
        nav_version = "2.5.3"
        room_version = "2.4.3"
        hilt_version = "2.44.2"
    }
}// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
    id 'com.android.application' version '7.3.1' apply false
    id 'com.android.library' version '7.3.1' apply false
    id 'org.jetbrains.kotlin.android' version '1.7.20' apply false
    id 'com.google.dagger.hilt.android' version '2.44' apply false

} ```
Anu answered 28/12, 2022 at 19:0 Comment(0)
W
18

Did you already figured this out? If not, maybe this can help you or others too!

You specified your dagger dependency like this:

//Dagger-Hilt
implementation "com.google.dagger:hilt-android-compiler:$hilt_version"
kapt "com.google.dagger:hilt-android-compiler:$hilt_version"

Remove the implementation since it only needs kapt

Write answered 3/8, 2023 at 17:0 Comment(1)
It works for me but how do you come up with the solution from the error message? 'META-INF/gradle/incremental.annotation.processors'. @WriteScibert
L
4

you use implementation for hilt compiler. Try to use

kapt "com.google.dagger:hilt-android-compiler:$hilt_version"
Lilianaliliane answered 3/6, 2023 at 12:33 Comment(1)
As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.Recidivism
N
4

Try adding this block in build.gradle.kts inside android {} block, Worked for me.

packaging {
    resources {
        excludes += "/META-INF/{AL2.0,LGPL2.1}"
        excludes += "/META-INF/gradle/incremental.annotation.processors"

    }
}
Nympho answered 28/2, 2024 at 7:43 Comment(1)
It has no compiler errors, but it produces a bunch of runtime errorsValor
L
0

I solved that problem by moving from that:

implementation(libs.hilt.android)
implementation(libs.hilt.compiler)
kapt(libs.hilt.compiler)

To that:

implementation(libs.hilt.android)
kapt(libs.hilt.compiler)

I should have deleted the second implementation since I am using kapt.

Laurilaurianne answered 28/8, 2024 at 17:14 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.