Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question GPS not work well on Android 12

Discussion in 'Android' started by Sherlore, Dec 15, 2021.

  1. Sherlore

    Sherlore

    Joined:
    Feb 26, 2014
    Posts:
    13
    Hello, I made a location-based game using Unity LocationService to access GPS.

    Everything was great. However, a player used to have perfect GPS experience with Android 11 updated his Google Pixel 5 to Android 12. Since that, the GPS location in my game became stuck or unstable.

    I searched the issue on internet. I found that several games had suffered same issue.
    (Jurassic World Alive) (Coin Hunt World)

    And I found that Android 12 have new permission rules on location
    (https://developer.android.com/training/location/permissions)

    But even if I tried to use
    Code (CSharp):
    1. Permission.RequestUserPermissions(new string[]{ Permission.CoarseLocation, Permission.FineLocation })
    to request both the ACCESS_FINE_LOCATION permission and the ACCESS_COARSE_LOCATION permission in a single runtime request as docs said, the GPS is still not ideal on player's Android 12 Google Pixel 5. The permission to access precise location is on after request as screenshot.

    For now, only running the Google Map in background (Start a navigation and minimize) makes GPS perfect again.

    Does anyone know how to fix it? Or is it confirmed a bug of Android 12, just need to wait it being fixed?

    Many thanks,
    Sherlore
     

    Attached Files:

  2. JuliusM

    JuliusM

    Unity Technologies

    Joined:
    Apr 17, 2013
    Posts:
    824
  3. Sherlore

    Sherlore

    Joined:
    Feb 26, 2014
    Posts:
    13
    Thank you! Glad to know is already in Issue Tracker. Look forward to the fix!
     
  4. apiotuch_unity

    apiotuch_unity

    Joined:
    Jun 28, 2019
    Posts:
    138
    @Unity Our app is unusable for Android users with Android 12 for a variety of devices. Any device we tested with Android 12 will not update position in app until we switch to google maps and wait for the position to change, and then switch back to the Unity App. Devices that no longer function: Pixel 3 XL, Samsung S21 plus, Samsung S20 5G, all of which are on Android 12 OS. The only way for our app to function as normal right now is if a user uses split screen to run Google maps at the same time as our app. We are currently using Unity 2020.3.7f1.

    Is there a temporary fix we can use until an official fix is included with a Unity release? We are already receiving complaints from users. Our app relies heavily on providing users with accurate location and is integral with the main gameplay mechanics.

    Edit:
    When testing other devices with Android 10 and 11 installed, those devices did not experience the issue. Devices: Samsung Note 9 (Android 10), Samsung A71 (Android 11). iOS devices also did not experience the issue.
     
    Last edited: Feb 19, 2022
  5. Sherlore

    Sherlore

    Joined:
    Feb 26, 2014
    Posts:
    13

    I haven't tried. But as the additional Information in Issue Tracker post, making your own android plugin that register GPS_PROVIDER explicitly may solve the issue.

    Besides using the split screen, running navigation in background coould let Unity get GPS update as well.
     
  6. apiotuch_unity

    apiotuch_unity

    Joined:
    Jun 28, 2019
    Posts:
    138
  7. apiotuch_unity

    apiotuch_unity

    Joined:
    Jun 28, 2019
    Posts:
    138
    I tried builds with both fine and coarse location in the manifest (fails to build), coarse instead of fine which builds but doesn't work (causes other issues with our app), and enabling background access with fine location which builds but has the same issue as with just fine.
     
  8. maadigitial

    maadigitial

    Joined:
    Apr 4, 2014
    Posts:
    4
    Just checking if there is any update on this - our App is experiencing the same issue.
     
  9. apiotuch_unity

    apiotuch_unity

    Joined:
    Jun 28, 2019
    Posts:
    138
    We made our own custom plugin as recommended in the Android issue tracker which mostly works for us. https://issuetracker.google.com/issues/215186921

    New releases of Unity also have supposedly fixed the issue but I have not tried them yet.
    2020.3.31f1
    2021.2.15f1
     
  10. Voronoi

    Voronoi

    Joined:
    Jul 2, 2012
    Posts:
    571
    I am struggling with this same issue, using a Google Pixel 2 and Android 11. I am using 2022.1.b13 and developing for iOS where everything works fine. It worked once, briefly, but I don't know why or what made it work, it fails consistently on numerous builds.

    How do I make a custom plug-in to get this working? I don't have access to newer Android devices for testing, but I'm not sure that would make a difference.