Skip to content

Build with Java 21 and run Robolectric on Android 16 - #74

Merged
hameno merged 1 commit into
masterfrom
feature/java_21
Oct 10, 2026
Merged

hameno merged 1 commit into
masterfrom
feature/java_21

Conversation

@hameno

@hameno hameno commented Oct 10, 2026

Copy link
Copy Markdown
Member

Every Robolectric test was pinned to @Config(sdk = [33]) because Robolectric needs Java 21 for current Android SDKs and the project was on Java 17.

  • Java toolchain, targetCompatibility and Kotlin jvmTarget 21; CI uses Temurin 21
  • app/src/test/resources/robolectric.properties runs all tests on SDK 36 (Android 16); the per-test SDK pins are gone
  • Test JVM args --add-opens=java.base/java.io=ALL-UNNAMED and --add-exports=java.base/jdk.internal.access=ALL-UNNAMED, which Robolectric needs on Java 17+
  • RobolectricSdkTest guards the SDK level
  • CLAUDE.md: JVM target 21

Why not SDK 37 (the app's target): the Compose UI tests fail there because androidx.test calls InputManager.getInstance(), which Android 17 removed.

Locally: 127 tests pass, lint has no errors, the release build succeeds, and a Java 21 debug build runs on a device.

🤖 Generated with Claude Code

Robolectric needs Java 21 for current Android SDKs, so every test was pinned
to SDK 33 to suit the Java 17 toolchain. The toolchain, bytecode target and
CI now use Java 21, and robolectric.properties runs all tests on SDK 36
(Android 17, the app's target, still breaks Compose input injection in
androidx.test). The test JVM gets the java.io/jdk.internal.access access
Robolectric needs on Java 17+, and a guard test checks the SDK.

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

Copy link
Copy Markdown

Test Results

127 tests  +1   127 ✅ +1   44s ⏱️ +13s
 35 suites +1     0 💤 ±0 
 35 files   +1     0 ❌ ±0 

Results for commit 56c16f6. ± Comparison against base commit 6220e6b.

@hameno
hameno merged commit d19e84a into master Oct 10, 2026
2 checks passed
@hameno
hameno deleted the feature/java_21 branch October 10, 2026 20:01
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.

1 participant