microg / microg/GmsCore

org.json.JSONException: Value null at lat of type org.json.JSONObject$1 cannot be converted to double

Open
#2,436 10 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Java
Stars
14.6k
Forks
3.2k
Avg merge
12d 11h
Merged PRs (30d)
4

Description

Describe the bug

java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:590)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:878)
Caused by: java.lang.reflect.InvocationTargetException
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:580)
	... 1 more
Caused by: org.json.JSONException: Value null at lat of type org.json.JSONObject$1 cannot be converted to double
	at org.json.JSON.typeMismatch(JSON.java:101)
	at org.json.JSONObject.getDouble(JSONObject.java:456)
	at org.microg.gms.location.network.ichnaea.ExtensionsKt.toResponseLocation(extensions.kt:83)
	at org.microg.gms.location.network.ichnaea.ExtensionsKt.toGeolocateResponse(extensions.kt:39)
	at org.microg.gms.location.network.ichnaea.IchnaeaServiceClient$rawGeoLocate$2$2.onResponse(IchnaeaServiceClient.kt:104)
	at org.microg.gms.location.network.ichnaea.IchnaeaServiceClient$rawGeoLocate$2$2.onResponse(IchnaeaServiceClient.kt:103)
	at com.android.volley.toolbox.JsonRequest.deliverResponse(JsonRequest.java:100)
	at com.android.volley.ExecutorDelivery$ResponseDeliveryRunnable.run(ExecutorDelivery.java:102)
	at android.os.Handler.handleCallback(Handler.java:959)
	at android.os.Handler.dispatchMessage(Handler.java:100)
	at android.os.Looper.loopOnce(Looper.java:232)
	at android.os.Looper.loop(Looper.java:317)
	at android.app.ActivityThread.main(ActivityThread.java:8592)
	... 3 more

To Reproduce

I don't know how to trigger this bug. But it happened only after I switch to https://beacondb.net as MLS provider.

Expected behavior

microG shouldn't crash when meet null as location lat. It's better to log and ignore it.

System
Android Version: 14
Custom ROM: LineageOS 21

Additional context

https://beacondb.net seems to return HTTP 404 and a Json below when it can't detect location. It may be microG treat it as success response and try to find lat member in Json?

{"error":{"code":404,"errors":[{"domain":"geolocation","message":"No location could be estimated based on the data provided","reason":"notFound"}],"message":"Not found"}}

And the server implementation of BeaconDB is here: https://codeberg.org/beacondb/beacondb

Contributor guide

No contributing guide indexed for this repository

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.

Research direction

Start in org.microg.gms.location.network.ichnaea.ExtensionsKt.toResponseLocation at extensions.kt:83 and trace the response flow through IchnaeaServiceClient.kt:104. Compare the BeaconDB 404 JSON with the expected geolocation response and determine how null or missing lat values are handled. Done means this response no longer causes the reported crash.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, java, kotlin
Domain
mobile-dev, networking
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.