Search code examples
androidandroid-manifestandroid-permissions

How do I remove the QUERY_ALL_PACKAGES permission from my android app?


My Google Play Update releases have been rejected 3 times due to this feedback from Google.

"Less broad app-visibility method should be used We are unable to approve your app’s use of QUERY_ALL_PACKAGES permission because the declared task can be done with a less broad app-visibility method."

My app doesn't need this permission and I have not declared this permission in my manifest file.

I have added the following queries element to my Manifest file to access the WhatsApp, Gmail package:

    <queries>

    <package android:name="com.whatsapp" />
    <package android:name="com.google.android.gm" />
    <intent>
        <action android:name="android.intent.action.SEND" />
        <data android:mimeType="text/plain" />
    </intent>

    <intent>
        <action android:name="android.intent.action.SEND" />
        <data android:mimeType="image/png" />
    </intent>

    <intent>
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.BROWSABLE" />
        <data android:scheme="https" />
    </intent>

</queries>

Here is the list of permissions asked:

    <uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<!-- Required only if your app targets Android 13. -->
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
<!-- Required to maintain app compatibility. -->
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"
    android:maxSdkVersion="33" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission
    android:name="android.permission.WRITE_EXTERNAL_STORAGE"
    android:maxSdkVersion="33" />
<!-- Required only if your app targets Android 13. -->
<uses-permission android:name="com.google.android.gms.permission.AD_ID" tools:node="remove" />

So how do I remove the query all packages permission? I don't need it and I have not asked for it.


Solution

  • As mentioned in the comments by @CommonsWare, there was a macro benchmark library that was added to the project initially when it was created. This library was asking for the "QUERY_ALL_PACKAGES" permission. I was unaware of the concept of "merged manifest file" and how different libraries used in the project declare their own permissions in their manifest file.

    Removed this library and Now its approved.