Ionic Cordova-如何在Android Manifest.xml中添加<permission>标签

问题描述

我可以使用这样的代码添加使用权限-

<edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/uses-permission" xmlns:android="http://schemas.android.com/apk/res/android">
            <uses-permission android:name="android.permission.INTERNET" />
</edit-config>

我使用以下相同的代码结构来添加权限,但是在添加Android平台时出现错误“无法在选择器“ / manifest / permission”处移植xml” 错误 / p>

<edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/permission" xmlns:android="http://schemas.android.com/apk/res/android">
            <permission android:name="test.mobile" />
</edit-config>

解决方法

使用配置文件代替在Android Manifest.xml中添加权限标签

<config-file parent="/manifest" target="app/src/main/AndroidManifest.xml" xmlns:android="http://schemas.android.com/apk/res/android">
            <permission android:name="test.mobile" />
</config-file>