Skip to content
Latchkey

Android "Failed to apply plugin 'com.android.application'" in CI

AGP runs initialization when it is applied. A failure here stops the build during configuration, and the nested cause names the real problem: an unsupported Gradle version, a JDK mismatch, or a missing Android SDK.

What this error means

The build fails with "Failed to apply plugin 'com.android.application'." followed by a cause such as "Minimum supported Gradle version is X" or "Android Gradle plugin requires Java 17 to run. You are currently using Java 11."

Android
> Failed to apply plugin 'com.android.application'.
  > Android Gradle plugin requires Java 17 to run. You are currently using Java 11.

Common causes

A JDK older than AGP requires

Recent AGP versions require Java 17; running the build on an older JDK fails plugin initialization.

An incompatible Gradle version or missing SDK

AGP needs a minimum Gradle and a resolvable Android SDK; either being wrong fails the apply step.

How to fix it

Run on the JDK AGP requires

  1. Read the nested cause to see what AGP wants.
  2. Pin the required JDK with setup-java for the build.
  3. Re-run so the plugin applies.
.github/workflows/ci.yml
- uses: actions/setup-java@v4
  with:
    distribution: 'temurin'
    java-version: '17'

Align Gradle and the SDK

Bump the Gradle wrapper to the minimum AGP needs and ensure the Android SDK is installed and located.

Terminal
./gradlew wrapper --gradle-version 8.7

How to prevent it

  • Match the JDK, Gradle wrapper, and AGP versions together.
  • Install and locate the Android SDK on the runner.
  • Read the AGP release note for its Java and Gradle requirements.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →