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

Résolution de 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.

Vous développez un application android ou vous mettez votre projet à jour. A l’exécution vous rencontrez un problème de taille. Le message d’erreur que vous trouvez c’est la suivante :

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

Dans notre cas, cette erreur est provoquée lorsqu’on initialise notre view model avec la nouvelle méthode d’invocation proposée par google.

private val viewModel : MainViewModel by viewModels()

Dans cet article nous allons vous donner la solution qui nous a permis de résoudre le problème.



Solution pour 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

Pour résoudre ce problème il faut modifier le fichier gradle . Le problème semble nous montrer qu’il ya conflit de versions . Dans votre gradle, modifiez le fichier pour qu’il ressemble à ceci.

compileOptions {

sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}

kotlinOptions {
    jvmTarget = JavaVersion.VERSION_1_8
}

Exécutez la solution et l’erreur devrais normalement disparaître.

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
Image par fotomecky de Pixabay

SUR LE MÊME THEME