Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash after granting permission. #1581

Closed
TGar21 opened this issue Jun 2, 2018 · 4 comments
Closed

Crash after granting permission. #1581

TGar21 opened this issue Jun 2, 2018 · 4 comments

Comments

@TGar21
Copy link

TGar21 commented Jun 2, 2018

Summary:
Commons crashing during granting a Location permission aftr first run. I am using Oreo device.
See the video: https://www.dropbox.com/s/3aig57i1x6pdcok/2018_06_02_17_20_08.mp4?dl=0

Steps to reproduce:

  1. Turn off the GPS permission
  2. Clear data
  3. Start app
  4. Go through the onboarding and sign in
  5. Press menu icon and choose Nearby option
  6. Dialogue asking for GPS permission appears, confirm it
  7. Add the permission in the settings and then in the dialogue

How can we reproduce the issue?
06-02 12:44:46.199 12044 12044 E AndroidRuntime: FATAL EXCEPTION: main 06-02 12:44:46.199 12044 12044 E AndroidRuntime: Process: fr.free.nrw.commons, PID: 12044 06-02 12:44:46.199 12044 12044 E AndroidRuntime: java.lang.RuntimeException: Failure delivering result ResultInfo{who=@android:requestPermissions:, request=1, result=-1, data=Intent { act=android.content.pm.action.REQUEST_PERMISSIONS (has extras) }} to activity {fr.free.nrw.commons/fr.free.nrw.commons.nearby.NearbyActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'double android.location.Location.getLatitude()' on a null object reference 06-02 12:44:46.199 12044 12044 E AndroidRuntime: at android.app.ActivityThread.deliverResults(ActivityThread.java:4581) 06-02 12:44:46.199 12044 12044 E AndroidRuntime: at android.app.ActivityThread.handleSendResult(ActivityThread.java:4631) 06-02 12:44:46.199 12044 12044 E AndroidRuntime: at android.app.ActivityThread.-wrap19(Unknown Source:0) 06-02 12:44:46.199 12044 12044 E AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1699) 06-02 12:44:46.199 12044 12044 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:105) 06-02 12:44:46.199 12044 12044 E AndroidRuntime: at android.os.Looper.loop(Looper.java:180) 06-02 12:44:46.199 12044 12044 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:6944) 06-02 12:44:46.199 12044 12044 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method) 06-02 12:44:46.199 12044 12044 E AndroidRuntime: at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240) 06-02 12:44:46.199 12044 12044 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:835) 06-02 12:44:46.199 12044 12044 E AndroidRuntime: Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'double android.location.Location.getLatitude()' on a null object reference 06-02 12:44:46.199 12044 12044 E AndroidRuntime: at fr.free.nrw.commons.location.LatLng.from(LatLng.java:45) 06-02 12:44:46.199 12044 12044 E AndroidRuntime: at fr.free.nrw.commons.location.LocationServiceManager.getLKL(LocationServiceManager.java:93) 06-02 12:44:46.199 12044 12044 E AndroidRuntime: at fr.free.nrw.commons.nearby.NearbyActivity.onRequestPermissionsResult(NearbyActivity.java:163) 06-02 12:44:46.199 12044 12044 E AndroidRuntime: at android.app.Activity.dispatchRequestPermissionsResult(Activity.java:7399) 06-02 12:44:46.199 12044 12044 E AndroidRuntime: at android.app.Activity.dispatchActivityResult(Activity.java:7250) 06-02 12:44:46.199 12044 12044 E AndroidRuntime: at android.app.ActivityThread.deliverResults(ActivityThread.java:4577) 06-02 12:44:46.199 12044 12044 E AndroidRuntime: ... 9 more

Expected behavior:
It should show the map.

Observed behavior:
Crash. After returning to the app again, the map is shown normally.

Device and Android version:
HTC 10, OS 8.0.0 Oreo, stock version

Commons app version:
2.7.1. downloaded from Play store

Video:

https://www.dropbox.com/s/3aig57i1x6pdcok/2018_06_02_17_20_08.mp4?dl=0

Would you like to work on the issue?

I would like to look at it. If I won't manage to fix this, I'll let you know.

@nicolas-raoul
Copy link
Member

Thanks for this great issue report, and for offering to start working on it, please let us know about everything you find out :-)

@TGar21
Copy link
Author

TGar21 commented Jun 5, 2018

I am sorry I won't be able to finish this I have less time than I thought I'll have. But I found out that the problem is that the line:

lastKL = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);

in the method getLKL() in the class LocationServiceManager can return null.

It is there as the second option used if the getLastKnownLocation with the GPS_PROVIDER returns null, but the code doesn't count with the option that also getLastKnownLocation with the NETWORK_PROVIDER could return null.

@hoplite390
Copy link
Contributor

Hi all, is this one sorted? If i download 2.8.4 on my Oreo phone from store and bug is still there. But when i forked master and installed app on emulator or phone i could not replicate the bug. Thx for info. (Trying to find something simple for my class to do)

hoplite390 added a commit to hoplite390/apps-android-commons that referenced this issue Oct 13, 2018
Hotfix for 2.8-release. Reintroduce lines from master to prevent crash: null chceck in LatLing getLKL method.
Fixing bug in NearbyActivity. Dialog was not dismissed in activity after pressing positive button and turning on GPS.
@domdomegg
Copy link
Member

See #1917, #1918 and #1933

Apochens added a commit to Apochens/Commons that referenced this issue Sep 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants