I am using view models and Hilt in my android app (Kotlin). But I have a issue when initializing my View model :
private val myViewModel: MyViewModel by viewModels()
The app compile fine and I can run it, but Android Studio indicates an error, and when I move my cursor above it I have the following message :
Cannot inline bytecode built with JVM target 1.8 into bytecode that is being built with JVM target 1.6. Please specify proper '-jvm-target'
In my build gradle I have specified Java 1.8 for Compile option (even for Kotlin).
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = JavaVersion.VERSION_1_8
}
Here are the annotations for my viewmodel and my fragment
@HiltViewModel
class MyViewModel: ViewModel()
And
@AndroidEntryPoint
class MyFragment: Fragment()
some of my dependencies :
'androidx.core:core-ktx:1.5.0'
'androidx.appcompat:appcompat:1.3.0'
'com.google.dagger:hilt-android:2.35'
'com.google.dagger:hilt-android-compiler:2.35'
"androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0"
Has anyone faced a similar issue ? Thank you for your help !