Search code examples
androidkotlindagger-hilt

Unsupported metadata version. Check that your Kotlin version is >= 1.0: java.lang.IllegalStateException


I changed my Kotlin version from 1.6.10 to 1.7.0.

from this

 implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.10'

upgrated to

 implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.0'

But Hilt throws an error. My Hilt version is 2.42. Is there a way to fix this without downgrading again? It works fine in Kotlin 1.6.10 and Hilt 2.42. But I want to use it by upgrading my kotlin version.

enter image description here


Solution

  • problem solved when i added it like this

    plugins {
                id 'androidx.navigation.safeargs' version '2.4.1'
                id 'dagger.hilt.android.plugin'
                id "org.jetbrains.kotlin.plugin.parcelize" version "1.6.0-M1"
                id 'com.android.library'
                id 'org.jetbrains.kotlin.android' version '1.7.0'
            }
        
          resolutionStrategy {
                eachPlugin {
                    if (requested.id.id == 'dagger.hilt.android.plugin') {
                        useModule("com.google.dagger:hilt-android-gradle-plugin:2.42")
                    }
                    if (requested.id.id == 'com.google.gms.google-services') {
                        useModule("com.google.gms:google-services:4.3.10")
                    }
                }
            }