Skip to content

build(android): Download Robolectric android-all jars with Gradle - #6553

Merged
runningcode merged 1 commit into
mainfrom
no/robolectric-android-all-gradle
Nov 11, 2026
Merged

runningcode merged 1 commit into
mainfrom
no/robolectric-android-all-gradle

Conversation

@runningcode

@runningcode runningcode commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

📜 Description

Adds an io.sentry.robolectric build-logic plugin, applied to the seven modules with Robolectric tests. Gradle now downloads the android-all jars the tests need, instead of Robolectric downloading them from Maven Central during the tests, as recommended in Improving android-all downloading.

  • The plugin lists the 8 API levels our tests use (21, 24, 28–31, 33, 35), one configuration per jar.
  • Tests read the jars straight from Gradle's cache through a small robolectric-deps.properties file, so nothing is copied.
  • A Robolectric upgrade can change the jar versions. A missing one fails the test with no artifacts found for org.robolectric:android-all-instrumented:…, and a comment in libs.versions.toml points to the plugin.

💡 Motivation and Context

This makes the downloads more reliable; it barely changes build speed. Gradle retries, respects proxy settings, and fetches each jar once per machine, before any test runs. Downloading in the middle of a test is what causes the flaky SHA-mismatch failures the post describes.

It is not a meaningful speedup: CI downloads all the jars in about 10 s. Because of the configuration cache, every check also resolves the jars, even when the tests come from the build cache. That's a local lookup once setup-gradle has them, but the Build job's cache grows by about 0.95 GB.

💚 How did you test it?

All Robolectric tests pass in the seven modules. With one API level removed from the list, its tests fail, so Robolectric never falls back to ~/.m2. On CI, the build scan shows each jar downloaded once, even though six modules resolved it.

📝 Checklist

  • I added GH Issue ID & Linear ID
  • I added tests to verify the changes.
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled.
  • I updated the docs if needed.
  • I updated the wizard if needed.
  • Review from the native team if needed.
  • No breaking change or entry added to the changelog.
  • No breaking change for hybrid SDKs or communicated to hybrid SDKs.
  • Public API changes reviewed by another Mobile SDK team member or implemented according to the develop docs spec.

🔮 Next steps

After merge, check that a PR's build scan shows no android-all downloads, to confirm setup-gradle keeps the jars between runs.

🤖 Generated with Claude Code

#skip-changelog

@runningcode
runningcode requested review from a team and adinauer as code owners November 11, 2026 09:37
@runningcode
runningcode requested review from 0xadam-brown and romtsn and removed request for a team November 11, 2026 09:37
@sentry

sentry Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

📲 Install Builds

Android

🔗 App Name App ID Version Configuration
SDK Size io.sentry.tests.size 8.63.0 (1) release

⚙️ sentry-android Build Distribution Settings

@0xadam-brown 0xadam-brown left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Robolectric fetched ~0.95 GB of android-all jars from Maven Central while
tests ran, and CI doesn't cache ~/.m2, so every Build run downloaded them
again. A new io.sentry.robolectric build-logic plugin resolves them with
Gradle before the tests start, so setup-gradle restores them from cache,
and points Robolectric at them through robolectric-deps.properties
instead of copying them into robolectric.dependency.dir.

See https://robolectric.org/blog/2023/11/11/improving-android-all-downloading/

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@runningcode
runningcode force-pushed the no/robolectric-android-all-gradle branch from d15fa0f to 55bccb8 Compare November 11, 2026 14:48
@runningcode
runningcode merged commit 393de0d into main Nov 11, 2026
48 checks passed
@runningcode
runningcode deleted the no/robolectric-android-all-gradle branch November 11, 2026 15:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants