Custom android.permission defined in .PRO
-
Hello.
I'm trying to create a custom build option for android permissions depending on the build needs.
I figured I could use
.PROfor this by addingANDROID_PERMISSIONS, which at first didn't add the permission toAndroidManifest.xml, till I added<!-- %%INSERT_PERMISSIONS -->toAndroidManifest.xml.Now all custom permissions defined with
ANDROID_PERMISSIONSare added, but... it adds even more, which is the issue.
I compared the 2 manifest files, one with<!-- %%INSERT_PERMISSIONS -->and one without.Turn out, qt also adds:
< <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> < <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> < <uses-permission android:name="android.permission.CAMERA"/> < <uses-permission android:name="android.permission.INTERNET"/>My question is, how to make it not add that, since it's not defined anywhere? Or if it is defined, I can't find it where.
-
Hello.
I'm trying to create a custom build option for android permissions depending on the build needs.
I figured I could use
.PROfor this by addingANDROID_PERMISSIONS, which at first didn't add the permission toAndroidManifest.xml, till I added<!-- %%INSERT_PERMISSIONS -->toAndroidManifest.xml.Now all custom permissions defined with
ANDROID_PERMISSIONSare added, but... it adds even more, which is the issue.
I compared the 2 manifest files, one with<!-- %%INSERT_PERMISSIONS -->and one without.Turn out, qt also adds:
< <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> < <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> < <uses-permission android:name="android.permission.CAMERA"/> < <uses-permission android:name="android.permission.INTERNET"/>My question is, how to make it not add that, since it's not defined anywhere? Or if it is defined, I can't find it where.
@Wiru I don't know for sure, but they may be added automatically, depending on your modules used 🤷♂️
what do you add with
QT += moduleNameand have checked: Add necessary permission in the project settings? Those may be at fault as well 🤔
-
I guess that might be true,
I haveqml quick multimedia network quickcontrols2 sql websockets widgetsSo I guess it adds them by itself, which I wish it wouldn't because some are defined already
I only ran a
difffor the 2 files, reason it outputted this:< <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> < <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> < <uses-permission android:name="android.permission.CAMERA"/> < <uses-permission android:name="android.permission.INTERNET"/>is because it added
WRITE_EXTERNAL_STORAGE, ACCESS_NETWORK_STATE, INTERNETtwice, once they are manually defined, and second is the automated one. so if I'd ignore the duplicates, only theCAMERAone is the issue. (ofc it would be nice if it didn't duplicate already existing permissions)I wanted to use this for CI, so it can be easily defined which additional permissions are needed for which project. Any other suggestion on how to handle it (I'd really love to skip patch files or script edits of manifest file)
EDIT: where is the "Add necessary permission in the project settings", can't seem to find it under
Projects > Build -
I guess that might be true,
I haveqml quick multimedia network quickcontrols2 sql websockets widgetsSo I guess it adds them by itself, which I wish it wouldn't because some are defined already
I only ran a
difffor the 2 files, reason it outputted this:< <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> < <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> < <uses-permission android:name="android.permission.CAMERA"/> < <uses-permission android:name="android.permission.INTERNET"/>is because it added
WRITE_EXTERNAL_STORAGE, ACCESS_NETWORK_STATE, INTERNETtwice, once they are manually defined, and second is the automated one. so if I'd ignore the duplicates, only theCAMERAone is the issue. (ofc it would be nice if it didn't duplicate already existing permissions)I wanted to use this for CI, so it can be easily defined which additional permissions are needed for which project. Any other suggestion on how to handle it (I'd really love to skip patch files or script edits of manifest file)
EDIT: where is the "Add necessary permission in the project settings", can't seem to find it under
Projects > Build@Wiru said in Custom android.permission defined in .PRO:
EDIT: where is the "Add necessary permission in the project settings", can't seem to find it under Projects > Build
actually, its inside the manifest.xml ui:

I assume this is a setting in QtCreator/project.pro.user file
Any other suggestion on how to handle it (I'd really love to skip patch files or script edits of manifest file
Don't rely on the auto creation of the manifest file,
make explicit (fixed) manifest files for your builds, and include them (in your pro) depending on the build.android { buildA: DISTFILES += builda/AndroidManifest.xml buildB: DISTFILES += buildb/AndroidManifest.xml -
@Wiru said in Custom android.permission defined in .PRO:
EDIT: where is the "Add necessary permission in the project settings", can't seem to find it under Projects > Build
actually, its inside the manifest.xml ui:

I assume this is a setting in QtCreator/project.pro.user file
Any other suggestion on how to handle it (I'd really love to skip patch files or script edits of manifest file
Don't rely on the auto creation of the manifest file,
make explicit (fixed) manifest files for your builds, and include them (in your pro) depending on the build.android { buildA: DISTFILES += builda/AndroidManifest.xml buildB: DISTFILES += buildb/AndroidManifest.xml@J-Hilk said in Custom android.permission defined in .PRO:
Don't rely on the auto creation of the manifest file,
make explicit (fixed) manifest files for your builds, and include them (in your pro) depending on the build.This would require to have a complete manifest for each include? (which might be unnecessary)
In my opinion it would be much better to just add permissions depending on needs, but I'll keep that as an option.For now I went the way I wanted to skip, writing a bash script to replace a placeholder in the manifest with needed permissions.