Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

679
Vistas
How do I set the jvm target for android studio using gradle and kotlin?

I get the following error when trying to compile a unit test written in kotlin.

Task :app:compileDebugUnitTestKotlin FAILED ...Cannot inline bytecode built with JVM target 1.7 into bytecode that is being built with JVM target 1.6. Please specify proper '-jvm-target' option

I've tried setting the source compatibility for my android configuration in my app build.gradle:

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}

as well as configuring all kotlin compile tasks in the root build.gradle:

tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
    kotlinOptions {
        jvmTarget = '1.8'
    }
}
over 4 years ago · Santiago Trujillo
3 Respuestas
Responde la pregunta

0

This is a temporary Android Studio bug. I needed to add these lines to the app's gradle file:

android {
    ...
    compileOptions {
        sourceCompatibility = 1.8
        targetCompatibility = 1.8
    }
    kotlinOptions {
        jvmTarget = "1.8"
    }
    ...
}
over 4 years ago · Santiago Trujillo Denunciar

0

1)On a Mac

Android Studio -> Preferences -> Kotlin Compiler -> Change Target JVM version

2) PC

Android Studio -> File -> Settings -> Kotlin Compiler -> Change Target JVM version

over 4 years ago · Santiago Trujillo Denunciar

0

The default target JVM bytecode is 1.6. But this can be set by changing build.gradle(:app):

android{
...
    kotlinOptions {
        jvmTarget = 1.8
    }
}

It seems, the Android Studio Kotlin compiler target JVM option does not work.

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda