Search Unity

  1. Calling all beginners! Join the FPS Beginners Mods Challenge until December 13.
    Dismiss Notice
  2. It's Cyber Week at the Asset Store!
    Dismiss Notice

[SOLVED] GPS Location Service not working on Android 6.0.1?

Discussion in 'Scripting' started by Jacky2611, Jul 17, 2016.

  1. Jacky2611

    Jacky2611

    Joined:
    Mar 2, 2013
    Posts:
    12
    Hi there!

    I am currently making a small map app to learn a few new things. Everything so far is working fine expect for the location Input.

    I am using:

    Code (CSharp):
    1.     public static IEnumerator Start()
    2.     {
    3.  
    4.         print("starting GPS LocationService");
    5.         // First, check if user has location service enabled
    6.         if (!Input.location.isEnabledByUser)
    7.             yield break;
    8.  
    9.         // Start service before querying location
    10.         Input.location.Start();
    11.  
    12.         print("starting GPS LocationService2 " + Input.location.status);
    13.  
    14.         // Wait until service initializes
    15.         int maxWait = 20;
    16.      
    17.         while (Input.location.status == LocationServiceStatus.Initializing && maxWait > 0)
    18.         {
    19.             yield return new WaitForSeconds(1);
    20.             maxWait--;
    21.         }
    22.  
    23.         // Service didn't initialize in 20 seconds
    24.         if (maxWait < 1)
    25.         {
    26.             print("Timed out");
    27.             yield break;
    28.         }
    29.  
    30.         // Connection has failed
    31.         if (Input.location.status == LocationServiceStatus.Failed)
    32.         {
    33.             print("Unable to determine device location");
    34.             yield break;
    35.         }
    36.         else
    37.         {
    38.             // Access granted and location value could be retrieved
    39.             print("Location: " + Input.location.lastData.latitude + " " + Input.location.lastData.longitude + " " + Input.location.lastData.altitude + " " + Input.location.lastData.horizontalAccuracy + " " + Input.location.lastData.timestamp);
    40.         }
    41.  
    42.         // Stop service if there is no need to query location updates continuously
    43.         //Input.location.Stop();
    44.     }

    And start it from my GameManagers Awake Methode using StartCoroutine(RPGPSLocationService.Start());
    The problem is that nothing happens. I do get the "Location:..." output, but the coordinates are 0 0 0 0 and the service status is "stopped". If I try to access the location from another Class Unity always tells me to start my location Service first.

    Could someone tell me what I am doing wrong? Its most likely something totally obvious, but I can't seem to find it :/.

    EDIT: nearly forgot to mention it: I am using a nexus 5x 6.0.1 and android monitor (comes with the sdk) to test my code

    Jacky
     
  2. Jacky2611

    Jacky2611

    Joined:
    Mar 2, 2013
    Posts:
    12
    Ok, so after I wrote my own little native Android gps script in java I tried my app on another Smartphone (5.0.2) and to my surprise the built in gps location worked nearly instantly. From the looks of it I would say that android 6 broke Unity's gps support. Can anyone confirm this? I don't want to file a bug report unless I am 100% certain.

    And how long does it usually take for something like this to get fixed after I reported it? It really sucks for me that I can't use my main device for debugging anymore. :/

    EDIT: Just tested it on the smartphones of a few of my friends. works fine on every android version below android 6.0.2. I decided to report this as a bug.
     
    Last edited: Jul 17, 2016
  3. Jacky2611

    Jacky2611

    Joined:
    Mar 2, 2013
    Posts:
    12
    Ok, I reset my android 6.0.1 devices to a stock rom and them updated them all the way back to 6.0.1 and now everything works fine. idk why, but i guess this is solved.