Azure build error: "Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8"
Asked Answered
R

2

11

When building Flutter app in azure devOps, I receive this error:

Build file 'D:\a\1\s\android\app\build.gradle' line: 24

* 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`.

I've tried, these solutions:

  • Creating jitpack.yml file, with - openjdk11 value.
  • Adding below lines to app/build.gradle file inside android {} block:

...

compileOptions {

sourceCompatibility JavaVersion.VERSION_11

    targetCompatibility JavaVersion.VERSION_11
}

kotlinOptions {
    jvmTarget = JavaVersion.VERSION_11.toString()
}

And another solutions, but my error doesn't solve. By the way, I easily run app and build apk, locally on my mac without any errors, but when I push my code, Azure gives those build error.

Roentgenotherapy answered 6/5, 2022 at 11:20 Comment(0)
R
25

My error is solved by adding below lines into azure-pipelines.yml file:

steps:
 - task: JavaToolInstaller@0
    inputs:
      versionSpec: '11'
      jdkArchitectureOption: 'x64'
      jdkSourceOption: 'PreInstalled'
Roentgenotherapy answered 6/5, 2022 at 11:23 Comment(0)
T
0

you can choose the JDK under advance section azure

Tonsillotomy answered 17/12, 2023 at 7:45 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.