Repository navigation
fix(cli): Find the Android app module when AGP comes from a version catalog - #2804
Merged
Merged
Conversation
…atalog
Android Studio projects created since 2023 apply the Android Gradle plugin
with `alias(libs.plugins.android.application)` and declare its id in
`gradle/libs.versions.toml`. `selectAppFile` matched only the literal
`com.android.application` id, so `sentry wizard android` asked for the
app's build file in every new project, a question no flag answers.
The app module is now also recognized when:
- its `plugins {}` block applies a `[plugins]` alias of the root project's
catalog whose id is `com.android.application`. Aliases and accessors are
compared with `-`, `_` and `.` normalized to `.`, as Gradle generates
them, so `android-application`, `android_application` and
`androidApplication` all resolve. `apply false`, as in the root build
script, does not count.
- it sets an `applicationId` in `defaultConfig`, which library modules
don't have.
The catalog is read with a small line-based reader of the `[plugins]`
table (inline, `id:version`, dotted-key and table forms), not a TOML
dependency. One, several, or no app modules are handled as before.
Co-Authored-By: Antonis Lilis <antonis.lilis@sentry.io>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
1 Skipped Deployment
|
antonis
marked this pull request as ready for review
December 2, 2026 16:16
antonis
approved these changes
Dec 2, 2026
antonis
added a commit
that referenced
this pull request
Dec 2, 2026
…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>
5 tasks
14 of 16 tasks
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This comes from testing the Android wizard port on fresh Android Studio (AGP 9) projects, see getsentry/sentry-java#6797.
Android Studio projects created since 2023 apply the Android Gradle plugin through the version catalog:
plugins { alias(libs.plugins.android.application) }with
gradle/libs.versions.tomldeclaringandroid-application = { id = "com.android.application", version.ref = "agp" }.selectAppFileonly matched the literalcom.android.applicationid, sosentry wizard androidfound no app module and asked "Unable to find your app's directory" in every new project. No flag answers that question, so runs without a terminal stopped there too.selectAppFilenow also treats a module as an app module when:plugins {}block applies an alias from the[plugins]table of the root project'sgradle/libs.versions.tomlwhose id iscom.android.application. Catalog keys and accessors are compared with-,_and.normalized to., as Gradle generates accessors, soandroid-application(libs.plugins.android.application) and older keys likeandroidApplication(libs.plugins.androidApplication) both resolve. Kotlinalias(…)and Groovyalias …both work.alias(…) apply false, as in the root build script, doesn't count, and commented-out lines are ignored.applicationIdindefaultConfig, which library modules don't have (testApplicationIdandapplicationIdSuffixdon't match).The literal match is unchanged, and so is what happens after detection: one app module is used directly, several are picked from a list, and none still asks for the path.
The catalog is read by
version-catalog.ts, a small line-based reader of the[plugins]table that handles the inline ({ id = "…" }),"id:version", dotted-key (alias.id = "…") and table ([plugins.alias]) forms. The CLI has no TOML parser, and this is too narrow to justify adding one.selectAppFilenow takes the root project directory, used to find the catalog and to resolve the build file paths.@sentry/wizard(getsentry/sentry-wizard) has the same detection and needs the same fix separately.via Antonis Lilis.
--
View Session [Sentry]