Skip to content

Android build errorGradle: “Execution failed for task ':app:...'”

An Android build stops with FAILURE: Build failed with an exception, then Execution failed for task ':app:compileDebugKotlin' (or mergeDebugResources, checkDebugAarMetadata, processDebugMainManifest, mergeDexDebug). The line itself only names the step that broke. The real cause is in the lines below it, and the task name tells you where to look.

Short answer

Scroll to What went wrong and read the indented lines under the task name; the last > line is usually the real cause. Run ./gradlew assembleDebug --stacktrace for the full detail. Then match the task: compile tasks mean a code or JDK/Kotlin version problem, merge and process resource tasks mean a broken resource or manifest, checkDebugAarMetadata means a library needs a higher compileSdk (or a newer Android Gradle Plugin), and mergeDex tasks mean a D8 dexing error such as the 64K method limit.

What the failing task tells you, and the fix

  1. 01

    Read the cause, not the task name

    “A message that starts with Execution failed for task means the failure happened while running that task, not while configuring the build.” Gradle, Troubleshooting builds

    Gradle prints the failing task first and nests the underlying error under it. Read to the deepest line, and rerun with --stacktrace or --info when the message is cut short.

    ./gradlew assembleDebug --stacktrace
    # Windows: gradlew.bat assembleDebug --stacktrace
  2. 02

    compileDebugKotlin or compileDebugJavaWithJavac

    A real compile error in your code or a plugin, or a version mismatch: Android Gradle Plugin 8 needs JDK 17 or newer, and Java and Kotlin must target the same JVM version. Point Android Studio’s Gradle JDK at JDK 17 or 21 and set one target for both. The kotlin block sits at the top level of the module’s build.gradle.kts, outside android, and jvmToolchain needs JDK 17 installed or a toolchain resolver plugin.

    android {
      compileOptions {
        sourceCompatibility = JavaVersion.VERSION_17
        targetCompatibility = JavaVersion.VERSION_17
      }
    }
    kotlin { jvmToolchain(17) }
  3. 03

    checkDebugAarMetadata

    A dependency was built against a newer Android API than your compileSdk. The message names the library and the version it needs. Raise compileSdk (not minSdk) to at least that version. A higher compileSdk, or the library itself, can also need a newer Android Gradle Plugin; the message says which version.

    android {
      compileSdk = 36
    }
  4. 04

    mergeDebugResources, processDebugMainManifest or mergeDexDebug

    “When one failure wraps another, the underlying cause is prefixed with >.” Gradle, Troubleshooting builds

    Resource tasks fail on a bad XML file, an invalid file name in res/, or a duplicate resource; manifest tasks fail on merge conflicts; dex tasks fail on D8 errors such as the 64K method limit (duplicate classes usually fail earlier, in checkDebugDuplicateClasses). The nested message names the file or class, so fix that one.

Checked against the vendor’s docs on : Gradle: Troubleshooting builds.

Rather hand it over?

Fixed scope, fixed price, paid upfront. The work happens in writing; no call needed.

Related: Android “Duplicate class” build error · Android “Manifest merger failed” · Flutter “Gradle task assembleDebug failed”

Questions

More on this error

Does ./gradlew clean fix it?

Only when the failure comes from stale build output, which is rare. Read the cause first; clean builds take longer and usually fail the same way.

It builds in Android Studio but fails in CI. Why?

Usually a different JDK or missing environment: CI uses its own Java version, Android SDK packages and signing setup. Print java -version and the Gradle JDK in the CI log and match them to your machine.

Can you fix it for me?

If one bug is the whole problem, the App Fix Ticket covers it: a written diagnosis first, then the fix. If the app has more going on, the Launch Check is a written check of the whole app. Each issue found is rated critical, high, medium or low, with where it is and how it was confirmed. No issues worth fixing, no charge. If the Launch Check finds nothing rated medium or higher, Simon refunds the full $450. You keep the report either way. This applies to the first 10 Launch Checks bought after October 30, 2026.

A different error?

Describe it and get a written quote

Send the error and what you were doing. You get a written scope, a fixed price and a timeline; Simon replies by email, usually within one business day.