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

330
Vistas
Gradle building android project with Java 1.8 even though java gradle toolchain is set to jdk 11
FAILURE: Build failed with an exception.
* Where:
Build file '/bitrise/src/app/build.gradle' line: 1
* What went wrong:
A problem occurred evaluating project ':app'.
> Failed to apply plugin 'com.android.internal.application'.
   > Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8.
     You can try some of the following options:
       - changing the IDE settings.
       - changing the JAVA_HOME environment variable.
       - changing `org.gradle.java.home` in `gradle.properties`.

Gradle detects locally installed JVMs Gradle chooses a JRE/JDK matching the requirements of the build (in this case a JVM supporting Java 14) If no matching JVM is found, it will automatically download a matching JDK from AdoptOpenJDK

Does Android Gradle Plugin support the new gradle toolchains? https://docs.gradle.org/current/userguide/toolchains.html

Notable libraries / plugins / versions

  • Running AGP 7.0.0-alpha03
  • Kotlin 1.4.21
  • Android Studio Arctic Fox Canary 3
  • jvmTarget 1.8
  • gradle wrapper 6.8-rc-1

App module gradle config below (some details removed)

android {

    java {
        toolchain {
            languageVersion = JavaLanguageVersion.of(11)
        }
    }

    kotlinOptions {
        jvmTarget = Versions.jdkNumber
        useIR = true
    }

    buildToolsVersion Config.buildToolsVersion
    compileSdkVersion Config.compileSdk

    buildFeatures {
        compose true
        dataBinding true
    }

    composeOptions {
        kotlinCompilerVersion Versions.kotlin_version
        kotlinCompilerExtensionVersion Versions.compose
    }

    androidExtensions {
        experimental = true
    }
}
over 4 years ago · Hanz Gallego
3 Respuestas
Responde la pregunta

0

You might check this out. I had a similar problem and it fixed it for me. This is Gradle's own "snippet" of code for the problem you're facing.

import org.jetbrains.kotlin.gradle.dsl.KotlinJvmCompile

plugins {
    id "org.jetbrains.kotlin.jvm" version "1.4.20"
}

repositories {
    jcenter()
}

// tag::compiler-kotlin[]
def compiler = javaToolchains.compilerFor {
    languageVersion = JavaLanguageVersion.of(11)
}

tasks.withType(KotlinJvmCompile).configureEach {
    kotlinOptions.jdkHome = compiler.get().metadata.installationPath.asFile.absolutePath
}
// end::compiler-kotlin[]

This was found at https://github.com/gradle/gradle/blob/master/subprojects/docs/src/snippets/java/toolchain-kotlin/groovy/build.gradle

I incorporated it in my project at https://github.com/7ep/r3z/blob/51cc69bb6396c34f0507b67763487c9bc171a03e/build.gradle#L36

Good luck!

Byron

over 4 years ago · Hanz Gallego Denunciar

0

Just solved this by adding jitpack.yml file in project root folder with content:

jdk:
  - openjdk11
  • Helpful reading: https://ayoubbenkhemis.medium.com/publish-android-library-with-jitpack-be00a29a8174
over 4 years ago · Hanz Gallego Denunciar

0

I had the same issue and found out that Bitrise Ubuntu Stack is using Java 8. In order to switch to java 11, a script step is required. Follow the below on how to do it.

Add a Script Step to the Workflow before any Step that uses Java in any way. The simplest way to do it is to place it as the first Step of the Workflow. Add the following commands to the Script content input of the Step:

sudo update-alternatives --set javac /usr/lib/jvm/java-11-openjdk-amd64/bin/javac
sudo update-alternatives --set java /usr/lib/jvm/java-11-openjdk-amd64/bin/java

export JAVA_HOME='/usr/lib/jvm/java-11-openjdk-amd64'
envman add --key JAVA_HOME --value '/usr/lib/jvm/java-11-openjdk-amd64'

The above info comes from Bitrise documentation. If you want to read more then follow link below. https://devcenter.bitrise.io/infrastructure/virtual-machines/#switching-to-java-11

over 4 years ago · Hanz Gallego 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