Home > Back-end >  Azure build error: "Android Gradle plugin requires Java 11 to run. You are currently using Java
Azure build error: "Android Gradle plugin requires Java 11 to run. You are currently using Java

Time:05-08

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.

CodePudding user response:

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

steps:
 - task: JavaToolInstaller@0
    inputs:
      versionSpec: '11'
      jdkArchitectureOption: 'x64'
      jdkSourceOption: 'PreInstalled'
  • Related