Skip to content

Conversation

rohit9625
Copy link
Collaborator

Description (required)

Fixes #6399

What changes did you make and why?

  • The app was crashing on opening certain screens because we are using the requireContext() method to retrieve context inside ContentProviders. So, I make them use the context property directly.
  • I could've solved it by adding an if condition for API < 30 and using context for lower APIs and requireContext() for higher APIs. I found it redundant as both are equivalent, because the context property can be null if called before the onCreate method, and requireContext() throws an exception in the same case.
  • Hence, adding multiple if conditions is just overhead.

Tests performed (required)

Tested prodDebug on Pixel 3 Emulator with API level 28.

Screenshots (for UI changes only)
None

It fixes crash when opening certain screens like Contribution Details, Bookmark, etc. on lower Android versions
@rohit9625 rohit9625 mentioned this pull request Aug 17, 2025
@RitikaPahwa4444 RitikaPahwa4444 merged commit 4f3f7b9 into commons-app:main Aug 23, 2025
1 check passed
Copy link

✅ Generated APK variants!

@rohit9625 rohit9625 deleted the fix/crash-on-lower-api branch August 30, 2025 04: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.

[Bug]: App crashes on API Level < 30 when opening Contribution, Bookmarks, etc.
2 participants