google / dagger

A fast dependency injector for Android and Java.
https://dagger.dev
Apache License 2.0
17.45k stars 2.02k forks source link

Issue with Dagger Hilt Upgrade from 2.48 to 2.49 - Unable to Load Class JavacBasicAnnotationProcessor #4385

Open HashemDeveloper opened 3 months ago

HashemDeveloper commented 3 months ago

Hi Dagger Hilt Team,

I encountered an issue while upgrading Dagger Hilt from version 2.48 to 2.49. Upon attempting the upgrade, the following error was thrown:

Unable to load class 'dagger.spi.shaded.androidx.room.compiler.processing.javac.JavacBasicAnnotationProcessor'
dagger.spi.shaded.androidx.room.compiler.processing.javac.JavacBasicAnnotationProcessor

Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)
- Re-download dependencies and sync project (requires network)
- The state of a Gradle build process (daemon) may be corrupt. Stopping all Gradle daemons may solve this problem.
- Stop Gradle build processes (requires restart)
- Your project may be using a third-party plugin which is not compatible with the other plugins in the project or the version of Gradle requested by the project.

Project Setup: In project.gradle:

plugins {
    ...
    id 'com.google.dagger.hilt.android' version '2.48' apply false
    ...
}

In all other app module.gradle files:

plugins {
    ...
    id 'kotlin-kapt'
    id 'dagger.hilt.android.plugin'
}
dependencies {
    // Dagger Hilt
    implementation libs.daggerhilt.version
    kapt libs.hilt.android.compiler
    implementation(libs.android.hilt.nav.v)
    implementation libs.android.hilt.nav.compose
}

The project setup and dependency configuration are consistent across modules, and this issue appears only after attempting to upgrade to 2.49.

Could you please provide guidance on how to resolve this issue? Any insights or suggestions to troubleshoot and fix the problem would be greatly appreciated.

Thank you!

kuanyingchou commented 3 months ago

Hi, @HashemDeveloper , this could happen if your Hilt Gradle Plugin version doesn't match the other Hilt dependencies. For example, in your project.gradle you could still be using 2.48 instead of 2.49:

id 'com.google.dagger.hilt.android' version '2.48' apply false