Where Android permissions come from in a Qt application

While preparing a release of my Qt-based Lines game for RuStore, I was asked to explain why the app requested WRITE_EXTERNAL_STORAGE. The game saves its state in its own data directory, so this permission was unexpected. It was absent from my source manifest but present in the generated Android package.

I traced the permissions through Qt deployment and Gradle manifest merging. Here is what my build contains, where the declarations originate, and how to exclude an unnecessary permission without modifying Qt.

Two build stages add permissions

The observations below refer to my local release build with Qt 6.11.2, Android API 28 as the minimum, target API 36, arm64-v8a, and Yandex Mobile Ads mediation 8.6.0.0. Dependency updates and build variants can change the result.

First, androiddeployqt reads the Android dependency metadata of the Qt modules used by the application. It inserts their permission declarations into a generated copy of the application manifest at this placeholder:

<!-- %%INSERT_PERMISSIONS -->

Second, the Android Gradle Plugin merges that manifest with manifests contributed by Android libraries. This happens during the build, before the APK or AAB is packaged. A permission may therefore come from a transitive dependency even when neither my C++ code nor my source manifest mentions it. See Qt manifest configuration and Android manifest merging.

Permissions added by Qt

Qt modulePermissionPurpose
Qt Coreandroid.permission.WRITE_EXTERNAL_STORAGELegacy access to shared external storage
Qt Coreandroid.permission.INTERNETNetwork access
Qt Networkandroid.permission.ACCESS_NETWORK_STATENetwork connectivity information

In this installation, the declarations are recorded in lib/Qt6Core_arm64-v8a-android-dependencies.xml and lib/Qt6Network_arm64-v8a-android-dependencies.xml under the Qt installation directory. Qt Network lists the same permission more than once in its metadata; the generated manifest contains one declaration.

The Qt Core source, qtbase/src/corelib/CMakeLists.txt, explicitly registers WRITE_EXTERNAL_STORAGE using qt_internal_add_android_permission. The resulting module dependency XML contains:

<permission name="android.permission.WRITE_EXTERNAL_STORAGE"/>

This is a module-level declaration. It is added without checking whether my application actually writes to shared storage. Supporting file access on older Android versions is a plausible historical explanation, but the inspected registration does not document the original rationale.

Permissions added by Android libraries

The table below lists the other declarations in my merged release manifest. The contributors are examples taken from the manifest merger report; several libraries may declare the same permission.

PermissionContributors in this buildRelated functionality
com.google.android.gms.permission.AD_IDYandex Mobile Ads, MyTarget and other advertising SDKsAdvertising identifier access
android.permission.READ_BASIC_PHONE_STATEGoogle Ads SDKBasic telephony state
android.permission.ACCESS_ADSERVICES_TOPICSGoogle Ads SDK, StartApp, Unity AdsAdvertising Topics API
android.permission.ACCESS_ADSERVICES_AD_IDGoogle Ads SDKAdServices advertising identifier
android.permission.ACCESS_ADSERVICES_ATTRIBUTIONGoogle Ads SDK, Unity Ads, Unity mediationAdvertising attribution
android.permission.ACCESS_WIFI_STATEAppLovin, StartApp, MaticooWi-Fi state information
android.permission.VIBRATEAppLovinVibration
com.android.vending.CHECK_LICENSEAppLovinGoogle Play licensing
android.permission.WAKE_LOCKAppNext, AndroidX WorkManagerWake-lock capability
android.permission.FOREGROUND_SERVICEAndroidX WorkManagerForeground-service capability
com.google.android.finsky.permission.BIND_GET_INSTALL_REFERRER_SERVICEInstall Referrer library, StartAppInstall attribution
com.amazon.privacypass.ATTESTVungle and Open Measurement SDK dependenciesAmazon attestation integration
net.geographx.LinesGame.DYNAMIC_RECEIVER_NOT_EXPORTED_PERMISSIONAndroidX CoreInternal signature-protected receiver permission

The app-specific receiver permission uses the application ID as its prefix, so another app will have a different name. AndroidX Core declares it for internal receiver protection; it is not a request to read user files.

com.android.vending.BILLING is also present. In my project it is explicitly declared in the source manifest and also contributed by Google Play Billing Library. INTERNET and ACCESS_NETWORK_STATE have additional contributors among the advertising libraries.

One detail worth checking is that com.google.android.libraries.ads.mobile.sdk:ads-mobile-sdk:1.3.1 is still present in the merger report, despite exclusions for other Google advertising artifacts in Gradle. Excluding one artifact does not exclude every library belonging to the same vendor.

The inspected final manifest contains no camera, microphone, contacts, ACCESS_FINE_LOCATION, or ACCESS_COARSE_LOCATION permission. This does not establish what data the SDKs collect: some information, such as an approximate location inferred from an IP address, does not require a location permission.

Why saving the game does not require storage permission

My game obtains its save directory using:

QString location = QStandardPaths::writableLocation(
    QStandardPaths::AppLocalDataLocation);

This is the application-specific data location. Android does not require storage permissions for internal app-specific files. App-specific external directories also do not require storage permissions on Android 4.4/API 19 and later. See Android app-specific storage.

The platform also documents that WRITE_EXTERNAL_STORAGE has no effect for applications targeting Android 11/API 30 or later. Its appearance in a manifest can nevertheless trigger questions from store tooling. These are separate issues: a declaration in the package, its runtime effect, and the data actually accessed by the application. See the permission reference.

Suppressing the permission in the application manifest

A project-level removal rule can be placed in the application manifest. Add the tools namespace to the existing root element and add a matching permission entry with tools:node="remove". The following fragment shows the relevant parts; keep the rest of the application manifest:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
          xmlns:tools="http://schemas.android.com/tools"
          package="net.geographx.LinesGame">

    <!-- %%INSERT_PERMISSIONS -->

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

    <!-- Keep the remaining manifest content here. -->
</manifest>

There are two relevant steps in Qt 6.11.2. In qtbase/src/tools/androiddeployqt/main.cpp, the deployment tool reads explicit uses-permission entries and removes their names from its automatic permission lists to avoid duplicates. Our removal entry therefore prevents Qt from inserting another ordinary declaration of the same permission.

Gradle then processes the manifest-merger removal marker. It removes the permission entry from the merged result and suppresses matching declarations contributed by lower-priority library manifests. No change to the Qt installation is needed. The rule is documented under manifest node markers.

Keep <!-- %%INSERT_PERMISSIONS -->: deleting the placeholder would disable automatic insertion of other Qt permissions too. The removal rule above targets just one permission. Rebuild and inspect the final artifact to confirm the result; the permission inventory in this article was captured before applying that rule.

Finding the source of a permission

I compare three files in the Qt Android deployment directory: the generated AndroidManifest.xml, the merged release manifest, and the manifest merger report. In this build the latter two are located at the following paths relative to that directory:

Get-Content 'build/intermediates/merged_manifests/release/processReleaseManifest/AndroidManifest.xml'
Get-Content 'build/outputs/logs/manifest-merger-release-report.txt'

The exact intermediate paths depend on the Android Gradle Plugin version and build variant. The merger report includes entries such as uses-permission#android.permission.ACCESS_WIFI_STATE, followed by the dependency manifests that contributed them. Android Studio also provides a Merged Manifest view. Check the release variant used for publication rather than assuming a debug build has the same permissions.

A manifest declaration is not proof that an SDK uses the permission on every run, and removing a declaration does not remove that SDK from the app. Store data disclosures need to account for actual SDK behavior as well as permissions. Before suppressing a permission, identify its contributors and verify that the affected functionality still works.

Leave a Reply

Your email address will not be published. Required fields are marked *