apache / cordova-android

Apache Cordova Android
https://cordova.apache.org/
Apache License 2.0
3.59k stars 1.52k forks source link

Cannot append permission into the AndroidManifest file #1359

Closed WuglyakBolgoink closed 2 months ago

WuglyakBolgoink commented 2 years ago

Bug Report

Problem

What is expected to happen?

add custom permissions from project config.xml (not from plugin)

What does actually happen?

add in config.xml file

<edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/uses-permission">
            <uses-permission android:name="android.permission.CAMERA" />
</edit-config>

or

<edit-config file="app/src/main/AndroidManifest.xml" mode="overwrite" target="/manifest/uses-permission">
            <uses-permission android:name="android.permission.CAMERA" />
</edit-config>

then remove android platform folder and build app again.

in result manifest file I can see permission.CAMERA but both modes (merge & overwrite) remove permission.INTERNET from the manifest file (or maybe any other first permission in the whole list)

Is it possible to append a new permissions into the manifest file?

Version information

Checklist

WuglyakBolgoink commented 2 years ago

related to https://github.com/apache/cordova-plugin-camera/issues/763

breautek commented 1 year ago

You're targeting uses-permission where edit-config edits the target in place.

I think what you're after is config-file instead, which does insertions.

The config-file element only allows you to append new children to an XML document tree. The children are XML literals to be inserted in the target document.

The syntax is slightly different, see the example in the docs. Let me know of this helps.