Resolution of 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’ option.
You are making an android application or you are making update of an existing app. At runtime you encounter a major error that with this message in your log.
cannot inline bytecode built with jvm target 17 into bytecode that is being built with jvm target 1.8. please specify proper '-jvm-target' option
Some variants of these error are :
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' option
cannot inline bytecode built with jvm target 11 into bytecode that is being built with jvm target 1.8. please specify proper '-jvm-target' option
Sometime, we, developer lose our cool and forget to take time to read the log error properly due to pressure and tireness.
The solution here stay in this keyword at the end of the error’s message :
... please specify proper '-jvm-target' option
In this article i will give you the solution that allowed us to solve the problem.
Solution for Cannot inline bytecode built with jvm target 17 into bytecode that is being built with jvm target 1.8. please specify proper ‘-jvm-target’ option
To solve this crash message, we have to obviously specify a proper -jvm target option. How to do it ? That’s what i will show you in this section.
In my experience, my errors was :
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' option
I believe that what i did to solve this can be used to solve any variant of these errors.
In our case, this error apparently was caused by our view model initialization with the new invocation method proposed by google at that time.
private val viewModel: MainViewModel by viewModels ()
To solve this problem you have to modify the gradle file. In gradle, we edit the file to look like this.
compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } kotlinOptions { jvmTarget = JavaVersion.VERSION_1_8 }
Adapt it to your case and try to run it to see if it is solved . Hope i help solved it.
Please send what work for in our comment.