bug(demo-android): getParcelableExtra crashes on API < 33 in PostsListActivity

Open Beginner friendly
#443 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
68/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Quiet
Tech stack
android, kotlin
Domain
mobile-dev

Research direction

Start in PostsListActivity.onCreate and compare the two getParcelableExtra calls with the existing version-branched pattern in EditorActivity. Apply that pattern to both calls, then verify that navigating to the posts list no longer crashes on Android API 24–32.

Written by the indexing model from the issue text.

Description

Context

In PR #433 (feat/demo-edit-existing-posts), the new PostsListActivity uses the two-argument getParcelableExtra(String, Class) API without a version guard.

Bug

In PostsListActivity.onCreate(), two calls use the API 33+ form:

val postType = intent.getParcelableExtra(EXTRA_POST_TYPE, PostTypeDetails::class.java)
val configuration = intent.getParcelableExtra(MainActivity.EXTRA_CONFIGURATION, EditorConfiguration::class.java)

The two-argument Intent.getParcelableExtra(String, Class<T>) overload was added in API 33 (TIRAMISU). The project's minSdk is 24. On any device running API 24–32, this will crash with NoSuchMethodError.

EditorActivity already has the correct version-branched pattern:

val configuration =
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
        intent.getParcelableExtra(MainActivity.EXTRA_CONFIGURATION, EditorConfiguration::class.java)
    } else {
        @Suppress("DEPRECATION")
        intent.getParcelableExtra<EditorConfiguration>(MainActivity.EXTRA_CONFIGURATION)
    }

No desugaring or AndroidX IntentCompat is present in the project to mitigate this.

Impact

The app will crash immediately when navigating to the posts list on any device running Android 12L (API 32) or below — covering every API level from 24 through 32.

Fix

Apply the same Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU branching pattern used in EditorActivity to both getParcelableExtra calls in PostsListActivity.

Dominant language
JavaScript
Stars
29
Forks
6
Avg merge
1d 9h
Merged PRs (30d)
41

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from wordpress-mobile/GutenbergKit

All issues in wordpress-mobile/GutenbergKit

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.