apps-android-commons: [Bug]: Attempt to read from null error in Explore -> Map fragment

Summary

This issue is caused when there are no elements in mediaList Maybe the issue caused when there are no media (images) available at specific coordinate.

Steps to reproduce

  1. Open Explore -> Map Fragment in App
  2. Go to Bihta, Patna, India or Coordinates = 25.5303740, 84.8597150 in map

Expected behaviour

Placeโ€™s images should appear on the map.

Actual behaviour

Toast message Error fetching nearby places. Attempt to read from null...

Device name

Samsung S21

Android version

Android 14

Commons app version

4.2.1-debug-HEAD~9be8df3

Device logs

java.lang.NullPointerException: Attempt to read from null array at fr.free.nrw.commons.explore.map.ExploreMapPresenter.getLatLngBounds(ExploreMapPresenter.java:223) at fr.free.nrw.commons.explore.map.ExploreMapPresenter.updateMapMarkers(ExploreMapPresenter.java:193) at fr.free.nrw.commons.explore.map.ExploreMapFragment.updateMapMarkers(ExploreMapFragment.java:433) at fr.free.nrw.commons.explore.map.ExploreMapFragment.lambda$populatePlaces$5$fr-free-nrw-commons-explore-map-ExploreMapFragment(ExploreMapFragment.java:413)

Screen-shots

https://github.com/commons-app/apps-android-commons/assets/114223204/3babe197-7160-4de2-8760-7035c0676d56

Would you like to work on the issue?

Yes

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 1
  • Comments: 21 (11 by maintainers)

Most upvoted comments

Thanks @ShashwatKedia it worked! on production server. But we will need to handle it since there can be a place on earth where are no images in that case there will be this error. So, we can show some dialog at that place to make user experience better.

Done Mr. @kanahia1 ๐Ÿ‘

Sure @rohit9625 I will look into #5487

Hey @rohit9625, I have added TODO for snackbar in https://github.com/commons-app/apps-android-commons/pull/5475, you can add code for snackbar and share a pull request. ๐Ÿ™Œ

@rohit9625 Your screenshot looks great! ๐Ÿ™‚

Ah wait, I was totally forgetting the context since yesterday, I am so sorry! ๐Ÿ˜ฑ

Please use โ€œNo pictures in this areaโ€.

Thanks! ๐Ÿ™‚

Indeed, I just tried with prodDebug in Siberia and get the same error: Screenshot_20240120-071808.png

@kanahia1 this might happen because you are using the betaDebug variant, as was the case here https://github.com/commons-app/apps-android-commons/issues/5255#issuecomment-1890995267, pointed out by @nicolas-raoul here: https://github.com/commons-app/apps-android-commons/issues/5255#issuecomment-1891572569. Does the issue persist in prodDebug variant as well?