Skip to content

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

@rohit9625

Description

@rohit9625

Summary

Whenever we try to open any of our contributions, the app crashes. It also crashes when opening the Bookmarks screen and opening other users' contributions from the Explore screen. We are using requireContext inside some classes or components that introduced requireContext on API 30. Hence, we get this crash saying NoSuchMethod for lower API levels.

Steps to reproduce

  1. Install and open the app on an Emulator/Physical device running Android 9 or lower
  2. From contributions list, click any of your contribution

Expected behaviour

The app should navigate to the contribution details screen

Actual behaviour

The app crashes

Device name

Pixel 3

Android version

Android 9

Commons app version

main

Device logs

java.lang.NoSuchMethodError: No virtual method requireContext()Landroid/content/Context; in class Lfr/free/nrw/commons/bookmarks/items/BookmarkItemsContentProvider; or its super classes (declaration of 'fr.free.nrw.commons.bookmarks.items.BookmarkItemsContentProvider' appears in /data/app/fr.free.nrw.commons-fvh-rnYZvaEzKS-lZRdLHg==/base.apk!classes11.dex)
    at fr.free.nrw.commons.bookmarks.items.BookmarkItemsContentProvider.query(BookmarkItemsContentProvider.kt:39)
    at android.content.ContentProvider.query(ContentProvider.java:1057)
    at android.content.ContentProvider.query(ContentProvider.java:1149)
    at android.content.ContentProvider$Transport.query(ContentProvider.java:241)
    at android.content.ContentProviderClient.query(ContentProviderClient.java:163)
    at android.content.ContentProviderClient.query(ContentProviderClient.java:146)
    at android.content.ContentProviderClient.query(ContentProviderClient.java:136)
    at fr.free.nrw.commons.bookmarks.items.BookmarkItemsDao.findBookmarkItem(BookmarkItemsDao.kt:121)
    at fr.free.nrw.commons.explore.depictions.WikidataItemDetailsActivity.updateBookmarkState(WikidataItemDetailsActivity.kt:268)
    at fr.free.nrw.commons.explore.depictions.WikidataItemDetailsActivity.onCreateOptionsMenu(WikidataItemDetailsActivity.kt:193)
    at android.app.Activity.onCreatePanelMenu(Activity.java:3481)
    at androidx.activity.ComponentActivity.onCreatePanelMenu(ComponentActivity.kt:470)
    at androidx.fragment.app.FragmentActivity.onCreatePanelMenu(FragmentActivity.java:287)
    at androidx.appcompat.view.WindowCallbackWrapper.onCreatePanelMenu(WindowCallbackWrapper.java:95)
    at androidx.appcompat.app.AppCompatDelegateImpl$AppCompatWindowCallback.onCreatePanelMenu(AppCompatDelegateImpl.java:3429)
    at androidx.appcompat.app.ToolbarActionBar.populateOptionsMenu(ToolbarActionBar.java:458)
    at androidx.appcompat.app.ToolbarActionBar$1.run(ToolbarActionBar.java:58)
    at android.os.Handler.handleCallback(Handler.java:873)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:193)
    at android.app.ActivityThread.main(ActivityThread.java:6669)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)

Screen-shots

Screen_recording_20250816_134356.webm

Would you like to work on the issue?

Yes

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions