Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

328
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda