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

420

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

steps:
 - task: JavaToolInstaller@0
    inputs:
      versionSpec: '11'
      jdkArchitectureOption: 'x64'
      jdkSourceOption: 'PreInstalled'
Share:
420
M Karimi
Author by

M Karimi

Updated on January 04, 2023

Comments

  • M Karimi
    M Karimi about 1 year

    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.