Skip to content

fix(cli): Keep the Android wizard going when ./gradlew fails - #2805

Merged
BYK merged 2 commits into
mainfrom
fix/android-wizard-gradle-check
Dec 2, 2026
Merged

BYK merged 2 commits into
mainfrom
fix/android-wizard-gradle-check

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

sentry wizard android runs ./gradlew (gradlew.bat on Windows) after adding the Sentry Gradle plugin. When that build failed, the wizard logged "The Gradle sync failed after adding the Sentry Gradle plugin…" and stopped with abort(). At that point only build.gradle had changed, so users got a half-done setup and a message blaming Sentry. The build often fails for reasons that have nothing to do with the plugin: Android Gradle plugin 9 needs JDK 17+, and the shell's java is often not the JBR Android Studio uses; no network; or a project that was already broken.

This is a regression from @sentry/wizard 9.1.0, which warned and continued. It turned up while testing on fresh Android Studio AGP 9 projects (getsentry/sentry-java#6797).

What changes:

  • A failed ./gradlew no longer stops the wizard. It warns that the build failed and that the cause may be the build environment rather than the plugin, lists the common causes, shows the last 20 lines of Gradle's stderr (where it prints FAILURE: Build failed with an exception and what went wrong), and keeps the docs link for setting up the plugin by hand. The manifest, test snippet, and sentry.properties steps still run.
  • The outro then says setup finished but the Gradle build verification failed, and asks to build the project in Android Studio to confirm. The plain success message only shows when the check passed or was skipped.
  • execute() attaches stdout and stderr to the error it rejects with. Its success value is unchanged.
  • addGradlePlugin returns { pluginAdded, gradleCheck } instead of a boolean. Its only return false was the Gradle failure; there was no path for "the plugin couldn't be added" (a file without a plugins {} block gets one inserted). The one real case is a build.gradle the wizard can't write (EACCES/EPERM/EROFS). That now has its own message ("Could not add the Sentry Gradle plugin…"), and still stops the wizard, since the test snippet won't compile without the plugin. Other write errors still throw and get reported. isPermissionError moves from completions.ts to fs-utils.ts so both can use it.
  • Telemetry: gradle-plugin-added stays; the new gradle-check tag is passed, failed, or skipped (plugin already present, or not added).

Open question: should a build.gradle that can't be written also continue to the manifest step, like 9.1.0 did? This PR keeps stopping there.

via Antonis Lilis.

--

View Session [Sentry]

The Android wizard stopped with abort() whenever ./gradlew failed after
adding the Sentry Gradle plugin, leaving build.gradle edited but no
manifest or test snippet, and blaming the Sentry plugin. The build often
fails for reasons outside the plugin: a shell JDK older than AGP 9 needs,
no network, or a project that was already broken. @sentry/wizard 9.1.0
warned and continued.

Warn with the end of Gradle's stderr and the common causes, finish the
setup, and end with an outro that says the build verification failed.
A build.gradle that can't be written is reported separately and still
stops the wizard. execute() now attaches stdout and stderr to its error.
Add a gradle-check tag next to gradle-plugin-added.

Co-Authored-By: Antonis Lilis <antonis.lilis@sentry.io>
@vercel

vercel Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
cli Ready Ready Preview Dec 2, 2026 4:40pm UTC
1 Skipped Deployment
Project Deployment Actions Updated
sentry-local Skipped Skipped Dec 2, 2026 4:40pm UTC

Request Review

…adle-check

Resolve the Android wizard test conflicts with #2804 and #2808: keep
writeActivity(), which returns the Activity's path, and define main's
writeAppWithActivity() on top of it; keep both fs imports; drop the
Sentry import that both sides added.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vercel
vercel Bot temporarily deployed to Preview – sentry-local December 2, 2026 16:39 Inactive
@BYK
BYK marked this pull request as ready for review December 2, 2026 21:07
@github-actions github-actions Bot added the risk: medium PR risk score: medium label Dec 2, 2026
@BYK
BYK added this pull request to the merge queue Dec 2, 2026
Merged via the queue into main with commit 564a781 Dec 2, 2026
40 of 42 checks passed
@BYK
BYK deleted the fix/android-wizard-gradle-check branch December 2, 2026 21:12
antonis added a commit that referenced this pull request Dec 3, 2026
…th-token-warning

Resolve the android-wizard.ts conflict with #2805: keep both PRs'
constants (GRADLE_PLUGIN_DOCS and the CI env vars) and both PRs' helpers
(the token warning helpers and warnGradleCheckFailed).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch was successfully deployed

1 active and 1 inactive deployments
Preview – cli — 9d12ad55 Deployed Dec 2, 2026 by vercel[bot]
Preview – sentry-local — 9d12ad55 Deployed Dec 2, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: medium PR risk score: medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants