quasarframework/quasar · error
Gradle build failed!
Error message
Gradle build failed!
What it means
During a Capacitor Android build, #buildAndroid shells out to the Gradle wrapper (gradlew assembleDebug/assembleRelease, plus any extra argv) inside <app>/android. The callback fires when Gradle exits non-zero; Quasar warns 'Gradle build failed!' and suggests building from the IDE with --ide.
Source
Thrown at app-vite/lib/modes/capacitor/capacitor-builder.js:141
const buildPath = this.ctx.appPaths.resolve.capacitor(
'android/app/build/outputs'
)
// Remove old build output
fse.removeSync(buildPath)
log('Building Android app...')
await spawnSync(
`./gradlew${process.platform === 'win32' ? '.bat' : ''}`,
[
`assemble${this.quasarConf.metaConf.debugging ? 'Debug' : 'Release'}`,
...this.argv._
],
{ cwd: this.ctx.appPaths.resolve.capacitor('android') },
() => {
warn()
warn('Gradle build failed!')
warn(
'As an alternative, you can use the "--ide" param and build from the IDE.'
)
warn()
}
)
fse.copySync(buildPath, this.#packagedDir)
}
}
View on GitHub (pinned to 4841521b5f)
Solutions
- Re-run with the full Gradle output visible (or run `./gradlew assembleDebug` in <app>/android directly) to see the real root-cause error above the warning.
- Verify JAVA_HOME points to a compatible JDK (17 for recent Android Gradle Plugin) and Android SDK platforms/build-tools are installed.
- Clean Gradle state: `cd src-capacitor/android && ./gradlew clean` and delete build/.gradle caches if corrupted.
- If you only need to open/edit natively, use `quasar dev -m capacitor -T android --ide` or build from Android Studio as the warning suggests.
- Ensure Capacitor android platform is synced (`npx cap sync android`) and AGP/Gradle versions match the installed Capacitor version.
Example fix
// before (shell) export JAVA_HOME=/usr/lib/jvm/java-8-openjdk quasar build -m capacitor -T android // after export JAVA_HOME=/usr/lib/jvm/java-17-openjdk cd src-capacitor/android && ./gradlew clean quasar build -m capacitor -T android
Defensive patterns
Strategy: try-catch
Validate before calling
// pre-flight checks before `quasar build -m capacitor -T android`
const { execSync } = require('child_process')
console.log('JAVA_HOME =', process.env.JAVA_HOME || '(unset)')
execSync('java -version', { stdio: 'inherit' }) // must be JDK 17+ for recent AGP
execSync('sdkmanager --list | head', { stdio: 'inherit' }) // Android SDK reachable
execSync('cd src-capacitor/android && ./gradlew --version', { stdio: 'inherit' }) Try / catch
// wrap the CLI invocation
try {
execSync('npx quasar build -m capacitor -T android', { stdio: 'inherit' })
} catch (err) {
console.error('Gradle build failed; inspect the gradlew output above, then retry with:\n cd src-capacitor/android && ./gradlew clean\n cd ../.. && quasar build -m capacitor -T android --ide')
process.exit(err.status || 1)
} Prevention
- Pin JAVA_HOME to JDK 17 for current Android Gradle Plugin versions.
- Run `npx cap sync android` after capacitor config or plugin changes.
- Keep AGP/Gradle wrapper versions aligned with the Capacitor version in use.
- Run `./gradlew clean` when builds fail after partial/interrupted runs.
- Read the gradlew stderr above the warning — Quasar only reports the failure, not the cause.
When it happens
Trigger: Running `quasar build -m capacitor -T android` (or dev) and the spawned `./gradlew assembleDebug|Release` process returns an error exit code; the warning callback of runGradle is invoked.
Common situations: Missing/incorrect ANDROID SDK or JAVA_HOME (JDK 17 required for recent AGP); compile errors in custom Java/Kotlin plugin code; corrupted Gradle cache or lock files; insufficient memory; mismatched AGP/Gradle versions after upgrading Capacitor; signing config errors in release builds.
Related errors
- As an alternative, you can use the "--ide" param and build f
- Failed to render ${errorsEncountered} SSG page${errorsEncoun
- quasar.config file > invalid Vite plugin specified (cannot f
- Capacitor support detected already. Aborting.
- No output folder found for target "${target}". Files have no
AI-assisted analysis of quasarframework/quasar@4841521b5f (2026-08-30).
Data as JSON: /api/errors/d24efe169e6a1ae3.
Report an issue: GitHub.