Search Issue Tracker

Fixed in 5.6.0f3

Fixed in 5.5.X, 5.6.X



Found in


Issue ID




[Android] Location app crashes due to error 'jstring has wrong type: android.location.Location'



How to reproduce:
1. Open the attached project
2. Build and Run Test scene on Android device (it has only one line Input.location.Start() in script)
3. When app launches, select "Allow" in the permission dialog
4. App will start and location service will start to initialize
5. Notice that app will crash in several second after beginning of location init

Reproducible: 5.5.0f1, 5.5.0f3, 5.6.0a5
Not reproducible: 5.5.0b11

Issue is not device specific

Comments (115)

  1. WinstonLegthigh

    Jan 15, 2017 16:07

    The issue is occurring for me on 5.5.0f3 and is blocking an app update I need to make. Please get this fixed ASAP.

  2. Twinsen3d

    Jan 15, 2017 05:38

    5.5.0f3 definitely broken on our android build.

  3. Phantom75

    Jan 13, 2017 15:33

    It blocks us from upgrading to 5.5 which is a pitty. Please fix asap, thank you!

  4. HugoCosta

    Jan 13, 2017 15:22

    Same problem here.

    How to use the workaround that JUSTKOG posted bellow?

  5. Cec

    Jan 11, 2017 09:11

    Still broken on 5.5.0p3

  6. justkog

    Jan 10, 2017 16:56


    Same issue here.

    Here is a basic example of a workaround using the Unity java wrapper:

    private AndroidJavaObject activityContext = null;
    private AndroidJavaObject locationManager = null;
    private LocationListener locationListener = null;

    public long MinDelaySeconds;
    public float MinDistanceMeters;

    public void ActivateGPS()
    using (AndroidJavaClass activityClass = new AndroidJavaClass("com.unity3d.player.UnityPlayer"))
    activityContext = activityClass.GetStatic<AndroidJavaObject>("currentActivity");
    locationManager = activityContext.Call<AndroidJavaObject>("getSystemService", "location");
    bool GPSenabled = locationManager.Call<bool>("isProviderEnabled", "gps");
    if (GPSenabled)
    Debug.Log("GPS enabled");
    Debug.Log("GPS disabled");

    // In case we need a startup location
    AndroidJavaObject lastLocation = locationManager.Call<AndroidJavaObject>("getLastKnownLocation", "gps");

    locationListener = new LocationListener();
    locationManager.Call("requestLocationUpdates", "gps", (long)1000 * MinDelaySeconds, MinDistanceMeters, locationListener);

    public static void DisplayJavaLocation(AndroidJavaObject location)
    double latitude = location.Call<double>("getLatitude");
    double longitude = location.Call<double>("getLongitude");

    Debug.Log("new latitude / longitude => " + latitude + " / " + longitude);

    class LocationListener : AndroidJavaProxy
    public LocationListener() : base("android.location.LocationListener")


    public void onLocationChanged(AndroidJavaObject location)

    public void onStatusChanged(string provider, int status, AndroidJavaObject bundle)
    Debug.Log(provider + " status changed to " + status); // 0 => OUT_OF_SERVICE / 1 => TEMPORARILY_UNAVAILABLE / 2 => AVAILABLE

    public void onProviderEnabled(string provider)
    Debug.Log(provider + " provider enabled");

    public void onProviderDisabled(string provider)
    Debug.Log(provider + " provider disabled");

    // the part below comes from

    static bool thatWasMe;

    // proxy for int java.lang.Object.hashCode()
    int hashCode()
    thatWasMe = true;
    return this.GetHashCode();

    // proxy for boolean java.lang.Object.equals(Object o)
    bool equals(AndroidJavaObject o)
    thatWasMe = false;
    return thatWasMe;

  7. XmmmX

    Jan 10, 2017 15:52

    Using Unity 5.5.0f3 over here and we are having the same issue when running our project on a Samsung Galaxy A3 and a Note 4 (we haven't tested it on any other smartphones so far). Strangely on our Commax Blade 80 Tablet the GPS works perfectly fine and the app does not crash but the performance is pretty bad. Hope this is going to be fixed very soon.

  8. AshyB

    Jan 10, 2017 09:46

    Same problem in 5.5.0f3

  9. grimmy

    Jan 05, 2017 21:08

    Blocked by this issue. Can't roll back for other reasons :(

  10. ssholtis

    Jan 04, 2017 16:55

    We are unable to release our application as this is a CORE feature we are relying on. What is the ETA? This is a Major issue which is blocking us?

Add comment

Log in to post comment

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.