Skip to content

Update targetSdk to 37 and Robolectric to 4.17-beta-2#24

Open
anod wants to merge 1 commit into
mainfrom
update-target-sdk-37-robolectric-beta
Open

Update targetSdk to 37 and Robolectric to 4.17-beta-2#24
anod wants to merge 1 commit into
mainfrom
update-target-sdk-37-robolectric-beta

Conversation

@anod

@anod anod commented Jul 23, 2026

Copy link
Copy Markdown
Owner

Summary

Bumps targetSdk to 37 (matching the project-wide compileSdk 37), migrates the deprecation warnings that have clean behavior-preserving replacements, and updates Robolectric so unit tests run natively at API 37.

Changes

Target SDK

  • targetSdk 35 → 37 (app) and 36 → 37 (baselineProfile)

Deprecation migrations (behavior-preserving, AndroidX compat)

  • IntentCompat.getParcelableExtra(..., Class) for typed parcelable extras — ShortcutInfoFactory, ModeDetector, ShortcutEditViewModel
  • ServiceCompat.stopForeground(STOP_FOREGROUND_REMOVE) in ModeService
  • Activity setShowWhenLocked() / setTurnScreenOn() + requestDismissKeyguard() instead of window keyguard flags in AcceptCallActivity
  • Platform Bundle instead of the deprecated androidx bundleOf in EditWidgetViewModel

This reduced deprecation warnings from 65 → 47; the remainder need larger refactors (TelephonyCallback, edge-to-edge, WorkManager, etc.) and are left as follow-ups.

Robolectric

  • 4.16.14.17-beta-2 for native API 37 support
  • Added --add-opens=java.base/jdk.internal.access=ALL-UNNAMED to the forked unit-test JVM (root build.gradle.kts); JDK 21's module system otherwise blocks Robolectric's FileDescriptor shadow at API 37

Submodule

Verification

  • ./gradlew :app:assembleDebug — SUCCESS
  • ./gradlew :compose:testAndroid :content:testAndroid --rerun-tasks — BUILD SUCCESSFUL
    • CompositeChooserLoaderTest runs at API 37 (no @Config pin), 0 failures
    • content tests pass (pinned @Config(sdk = [31]))

Bump targetSdk 35->37 (app) and 36->37 (baselineProfile) to match the
project-wide compileSdk 37, and migrate the deprecation warnings that have
clean, behavior-preserving AndroidX-compat replacements.

Deprecation migrations:
- IntentCompat.getParcelableExtra(..., Class) for typed parcelable extras
  (ShortcutInfoFactory, ModeDetector, ShortcutEditViewModel)
- ServiceCompat.stopForeground(STOP_FOREGROUND_REMOVE) in ModeService
- Activity setShowWhenLocked/setTurnScreenOn + requestDismissKeyguard instead
  of window keyguard flags in AcceptCallActivity
- Platform Bundle instead of the deprecated androidx bundleOf in EditWidgetViewModel

Robolectric:
- Update 4.16.1 -> 4.17-beta-2 for native API 37 support
- Add --add-opens=java.base/jdk.internal.access=ALL-UNNAMED to the forked
  unit-test JVM; JDK 21's module system otherwise blocks Robolectric's
  FileDescriptor shadow when running at API 37

Advance the lib submodule to the merged PackageInfoCompat version-code change.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: deb19a46-a1a3-40c2-a9b3-a539e068631e
Copilot AI review requested due to automatic review settings July 23, 2026 11:53

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Updates the project’s Android SDK targeting and test tooling so the app targets API 37 and Robolectric unit tests can run against API 37 without pinning lower SDKs.

Changes:

  • Bumped targetSdk to 37 for app and baselineProfile.
  • Migrated several deprecated APIs to their AndroidX/modern equivalents (typed parcelable extras, foreground-stop API, lockscreen/window behavior, and bundle creation).
  • Updated Robolectric to 4.17-beta-2 and added a Gradle-wide unit-test JVM --add-opens flag to support API 37+ shadows on JDK 17+.

Reviewed changes

Copilot reviewed 10 out of 11 changed files in this pull request and generated no comments.

Show a summary per file
File Description
gradle/libs.versions.toml Updates Robolectric version to 4.17-beta-2 via the version catalog.
content/src/androidMain/kotlin/info/anodsplace/carwidget/content/shortcuts/ShortcutInfoFactory.kt Replaces deprecated getParcelableExtra calls with IntentCompat.getParcelableExtra for typed retrieval.
compose/src/androidMain/kotlin/info/anodsplace/carwidget/shortcut/ShortcutEditViewModel.kt Migrates typed parcelable extra retrieval for a bitmap icon.
compose/src/androidMain/kotlin/info/anodsplace/carwidget/appwidget/EditWidgetViewModel.kt Replaces bundleOf usage with platform Bundle construction for extras.
build.gradle.kts Adds --add-opens for all Gradle Test tasks to support Robolectric on JDK 17+.
baselineProfile/build.gradle.kts Bumps targetSdk to 37.
app/src/main/java/com/anod/car/home/incar/ModeService.kt Migrates deprecated stopForeground(true) to ServiceCompat.stopForeground(..., STOP_FOREGROUND_REMOVE).
app/src/main/java/com/anod/car/home/incar/ModeDetector.kt Migrates deprecated getParcelableExtra calls to IntentCompat.getParcelableExtra.
app/src/main/java/com/anod/car/home/incar/AcceptCallActivity.kt Migrates deprecated window/keyguard flags to setShowWhenLocked/setTurnScreenOn + requestDismissKeyguard.
app/build.gradle.kts Bumps targetSdk to 37.

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