Xamarin Android Produced Bundle showing android.permission.ACCESS_BACKGROUND_LOCATION, but not asked for in AndroidManifest.xml

Tony Pitman 81 Reputation points
2022-02-07T15:47:11.47+00:00

I am using Xamarin Forms to produce a cross platform app. I am using the latest Visual Studio 2019 for Mac. When I submit my app to the google play store they keep saying that I need a message telling the user why I need background location services. This is confusing to me because in my code I use this request:

Permissions.RequestAsync<Permissions.LocationWhenInUse>

On top of that when I look at the options on the permissions page the AccessBackgroundLocation checkbox is NOT checked.

Here is what is in my AndroidManifest.xml:

    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.BLUETOOTH" />
    <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />

Yet when I look at the App Bundle on the google play website for this app here is what I see:

Required permissions (12)
12 COMMON
android.permission.ACCESS_BACKGROUND_LOCATION, android.permission.ACCESS_COARSE_LOCATION, android.permission.ACCESS_FINE_LOCATION, android.permission.ACCESS_NETWORK_STATE, android.permission.BATTERY_STATS, android.permission.BLUETOOTH, android.permission.BLUETOOTH_ADMIN, android.permission.BLUETOOTH_PRIVILEGED, android.permission.INTERNET, android.permission.READ_EXTERNAL_STORAGE, android.permission.RECEIVE_BOOT_COMPLETED, android.permission.WRITE_EXTERNAL_STORAGE

I don't understand where the requirement for ACCESS_BACKGROUND_LOCATION is coming from and how to turn that off in Xamarin when I build.

Developer technologies | .NET | Xamarin
{count} votes

1 answer

Sort by: Most helpful
  1. JarvanZhang 23,971 Reputation points
    2022-02-11T08:30:23.993+00:00

    Hello @Tony Pitman ,​

    Welcome to our Microsoft Q&A platform!

    When targeting Android.9 and lower, ACCESS_FINE_LOCATION and ACCESS_COARSE_LOCATION imply ACCESS_BACKGROUND_LOCATION. So if you want to remove the ACCESS_BACKGROUND_LOCATION permission, then you can not request ACCESS_FINE_ LOCATION or ACCESS_COARSE_LOCATION permission in your application.

    For how to remove the ACCESS_BACKGROUND_LOCATION permission, please add tools:node="remove" to the uses-permission tag as below:

       <uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION"  tools:node="remove" />  
    

    Best Regards,

    Jarvan Zhang


    If the response is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.