Skip to content

Replace deprecated androidx.core.os.bundleOf with direct Bundle methods#148

Merged
mmathieum merged 3 commits into
masterfrom
copilot/remove-bundleof-deprecation
Mar 12, 2026
Merged

Replace deprecated androidx.core.os.bundleOf with direct Bundle methods#148
mmathieum merged 3 commits into
masterfrom
copilot/remove-bundleof-deprecation

Conversation

Copilot AI commented Mar 11, 2026

Copy link
Copy Markdown
Contributor
  • Replace bundleOf with Bundle().apply { ... } in all 16 affected files
  • Remove all import androidx.core.os.bundleOf statements
  • Fix accidentally removed imports:
    • RDSDirectionStopsFragment.kt: restore import androidx.annotation.ColorInt
    • ServiceUpdatesDialog.kt: restore import androidx.core.content.ContextCompat
Original prompt

This section details on the original issue you should resolve

<issue_title>AndroidX Core bundleOf is Deprecated, replace it.</issue_title>
<issue_description>androidx.core.os.bundleOf if deprecated

Deprecated the bundleOf(...) extension function, which does not provide compile time type safety and may lead to crashes at run time. Instead, use Bundle methods directly. (I48af2, b/434825212)

bundleOf code:
https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:core/core-ktx/src/main/java/androidx/core/os/Bundle.kt

-> all androidx.core.os.bundleOf import should be removed

Example:

  • before:
bundleOf(
    "key1" to "value1",
    "key2" to 2,
    "key3" to true,
)
  • after:
Bundle().apply {
    putCharSequence("key1", "value1")
    putInt("key2", 2)
    putBoolean("key3", true)
}

Needed for:

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Co-authored-by: mmathieum <177998+mmathieum@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix deprecation of androidx.core.os.bundleOf Replace deprecated androidx.core.os.bundleOf with direct Bundle methods Mar 11, 2026
@github-actions

github-actions Bot commented Mar 11, 2026

Copy link
Copy Markdown

Qodana for JVM

It seems all right 👌

No new problems were found according to the checks applied

☁️ View the detailed Qodana report

Contact Qodana team

Contact us at qodana-support@jetbrains.com

@mmathieum

Copy link
Copy Markdown
Member

@copilot here is a build failure:

e: file:///home/runner/work/mtransit-for-android/mtransit-for-android/app-android/src/main/java/org/mtransit/android/ui/rds/route/direction/RDSDirectionStopsFragment.kt:179:10 Unresolved reference 'ColorInt'.
e: file:///home/runner/work/mtransit-for-android/mtransit-for-android/app-android/src/main/java/org/mtransit/android/ui/serviceupdates/ServiceUpdatesDialog.kt:92:41 Unresolved reference 'ContextCompat'.

…ompat in ServiceUpdatesDialog

Co-authored-by: mmathieum <177998+mmathieum@users.noreply.github.com>

Copilot AI commented Mar 12, 2026

Copy link
Copy Markdown
Contributor Author

@copilot here is a build failure:

e: file:///home/runner/work/mtransit-for-android/mtransit-for-android/app-android/src/main/java/org/mtransit/android/ui/rds/route/direction/RDSDirectionStopsFragm...

Fixed in 6f0c7db — the @ColorInt import (androidx.annotation.ColorInt) and ContextCompat import (androidx.core.content.ContextCompat) were accidentally dropped when removing the bundleOf import lines. Both are now restored.

@mmathieum mmathieum marked this pull request as ready for review March 12, 2026 12:07
@mmathieum mmathieum merged commit 0777341 into master Mar 12, 2026
7 checks passed
@mmathieum mmathieum deleted the copilot/remove-bundleof-deprecation branch March 12, 2026 12:09
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.

AndroidX Core bundleOf is Deprecated, replace it.

2 participants