Search Issue Tracker
Fixed in 5.6.0f3
Fixed in 5.5.X, 5.6.X
Votes
234
Found in
5.5.0f3
Issue ID
856773
Regression
Yes
[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
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- Crash when total memory consumption is over 2GB
- Red dots are rendered when copying texture with ASTC format and CompressGpu
- [Linux] "Trying to load color backbuffer into a complex RenderPass setup" error is thrown after entering Play mode in AR Mobile template project
- [Android] Neither of the callbacks are called when several videos with VideoPlayer are spawned on the target on the Google Pixel devices
- Texture2D memory allocation size is significantly increased when running on iOS device
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.
Twinsen3d
Jan 15, 2017 05:38
5.5.0f3 definitely broken on our android build.
Phantom75
Jan 13, 2017 15:33
It blocks us from upgrading to 5.5 which is a pitty. Please fix asap, thank you!
HugoCosta
Jan 13, 2017 15:22
Same problem here.
How to use the workaround that JUSTKOG posted bellow?
Cec
Jan 11, 2017 09:11
Still broken on 5.5.0p3
justkog
Jan 10, 2017 16:56
Hello,
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()
{
#if UNITY_ANDROID
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");
else
Debug.Log("GPS disabled");
// In case we need a startup location
AndroidJavaObject lastLocation = locationManager.Call<AndroidJavaObject>("getLastKnownLocation", "gps");
DisplayJavaLocation(lastLocation);
locationListener = new LocationListener();
locationManager.Call("requestLocationUpdates", "gps", (long)1000 * MinDelaySeconds, MinDistanceMeters, locationListener);
}
#endif
}
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)
{
DisplayJavaLocation(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 https://forum.unity3d.com/threads/androidjavaproxy-equals.243438/
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;
o.Call<int>("hashCode");
return thatWasMe;
}
}
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.
AshyB
Jan 10, 2017 09:46
Same problem in 5.5.0f3
grimmy
Jan 05, 2017 21:08
Blocked by this issue. Can't roll back for other reasons :(
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?