I'm facing issue while adding hilt dependencies in my project
plugins
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
id 'kotlin-kapt'
id 'realm-android'
id 'androidx.navigation.safeargs.kotlin'
id 'kotlin-parcelize'
}
dependencies
//Dependency injection with Hilt
implementation("com.google.dagger:hilt-android:2.38.1")
kapt("com.google.dagger:hilt-android-compiler:2.38.1")
implementation 'androidx.core:core-ktx:1.8.0'
implementation 'androidx.appcompat:appcompat:1.4.2'
implementation 'com.google.android.material:material:1.6.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
build.gradle project level
buildscript {
dependencies {
classpath 'com.android.tools.build:gradle:7.2.1'
classpath "io.realm:realm-gradle-plugin:10.11.1"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.10"
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:2.5.0"
classpath "com.google.dagger:hilt-android-gradle-plugin:2.42"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
plugins {
id 'com.android.application' version '7.2.1' apply false
id 'com.android.library' version '7.2.1' apply false
id 'org.jetbrains.kotlin.android' version '1.7.0' apply false
}
task clean(type: Delete) {
delete rootProject.buildDir
}
I have tried below answers from Stack Overflow but didn't find the solutions
Hilt Unsupported metadata version in Kotlin
Unsupported metadata version. Check that your Kotlin version is >= 1.0: java.lang.IllegalStateException
Upgrading Android kotlin version to 1.5.0 throwing error message on build
What can I try next?
Adding the below dependency fixed it for me. I did not have Hilt in my code but had Dagger 2.41
kapt "org.jetbrains.kotlinx:kotlinx-metadata-jvm:0.5.0"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With