Skip to content

Resolving "Could not resolve com.android.tools.build:gradle:8.0.1" Error

Problem Statement

You encounter this error when your Android project requires Java 17 compatibility but is configured to use Java 8 or Java 11. The core issue is a mismatch between Android Gradle Plugin (AGP) requirements and your project's Java configuration:

log
Could not resolve com.android.tools.build:gradle:8.0.1
...
Incompatible because this component declares an API of a component compatible with Java 11
and the consumer needed a runtime of a component compatible with Java 8

Key Causes

  • AGP 8.0+ requires Java 17
  • Your project is using an older Java version (8 or 11)
  • Gradle JDK settings are misconfigured in Android Studio
  • Gradle wrapper version is incompatible with AGP 8.0.1

Primary Solution: Update Gradle JDK to Java 17

In Android Studio

  1. Open Settings/Preferences (File > Settings on Windows/Linux, Android Studio > Preferences on macOS)
  2. Navigate to: Build, Execution, Deployment > Build Tools > Gradle
  3. Under Gradle JDK, select JDK 17
  4. Click Apply and sync your project

TIP

If JDK 17 isn't listed, install it via File > Project Structure > SDKs > Add JDK

For Command Line/Gradle Wrapper

Set JAVA_HOME to your JDK 17 installation:

Windows:

cmd
setx JAVA_HOME "C:\path\to\jdk-17" /M

Linux/macOS:

bash
export JAVA_HOME=/path/to/jdk-17

Alternative Solutions

1. Update Gradle Wrapper Version

Edit gradle-wrapper.properties to use Gradle 8.2+:

properties
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip

Compatibility Note

  • AGP 8.0.x requires Gradle 8.0-8.1
  • AGP 8.2.x requires Gradle 8.2

2. Verify AGP Version

Ensure your AGP version matches the Gradle version:

groovy
buildscript {
    dependencies {
        classpath 'com.android.tools.build:gradle:8.2.0'
    }
}

3. Clean Gradle Cache (Optional)

If issues persist, clean the Gradle cache:

bash
# Windows:
rmdir /s /q %USERPROFILE%\.gradle\caches

# Linux/macOS:
rm -rf ~/.gradle/caches

Additional Checks

For Kotlin Projects

Ensure Java toolchain compatibility:

kotlin
kotlin {
    jvmToolchain(17)
}

Common Pitfall

Avoid downgrading Java compatibility settings like this in AGP 8+ projects:

groovy
compileOptions {
    sourceCompatibility JavaVersion.VERSION_17  // Required for AGP 8+
    targetCompatibility JavaVersion.VERSION_17
}

Conclusion

This error occurs because AGP 8.0+ requires Java 17 support at both the Gradle runtime and project configuration levels. The most reliable solution is:

  1. Update Gradle JDK to Java 17
  2. Use compatible Gradle wrapper distribution (8.x)
  3. Verify AGP version matches Gradle requirements

For Android Studio users, the JDK setting is the key resolution. Command-line users should set JAVA_HOME to JDK 17 before running Gradle commands.

Future-Proofing