Search code examples
androidkotlindependency-injectionandroid-jetpack-composedagger

Caused by: java.lang.ClassNotFoundException: Didn't find class "com.example.hiltapp.Hilt_HiltApplication" on path: DexPathList


I'm trying to set up dagger hilt in my compose project, but it seems like dagger can't find an Application class, although it does exist

@HiltAndroidApp
class HiltApplication:Application()
@AndroidEntryPoint
class MainActivity : ComponentActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContent {
            HiltAppTheme {
                Surface(
                    modifier = Modifier.fillMaxSize(),
                    color = MaterialTheme.colorScheme.background
                ) {

                }
            }
        }
    }
}

android:name=".HiltApplication" inside of AndroidManifest has been written

Hilt dependecies were installed as follows:

Root build.gradle

plugins {
    id("com.android.application") version "8.2.0" apply false
    id("org.jetbrains.kotlin.android") version "1.9.0" apply false
    id("com.google.devtools.ksp") version "1.9.10-1.0.13" apply false
    id("com.google.dagger.hilt.android") version "2.44" apply false
}

Module build.gradle

plugins {
id("com.android.application")
id("org.jetbrains.kotlin.android")
id("com.google.devtools.ksp")
id("com.google.dagger.hilt.android")
}
implementation("com.google.dagger:hilt-android:2.44")
ksp("com.google.dagger:hilt-compiler:2.44")
ksp("androidx.hilt:hilt-compiler:1.1.0")

Also, another error gets printed:

Caused by: java.lang.ClassNotFoundException: Didn't find class "com.example.hiltapp.Hilt_HiltApplication" on path: DexPathList


Solution

  • Updating my hilt version from 2.44 to 2.50 fixed the issue.