我没有成功地在我的Cordova应用程序的manifest文件上设置tools
命名空间。正确的方法是在config.xml
中使用<edit-config>
标签,如下所示:
<edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest">
<manifest xmlns:tools="http://schemas.android.com/tools" />
</edit-config>
。然后,我使用它来修改<uses-permission>
标记,如下所示:
<config-file parent="/manifest" target="app/src/main/AndroidManifest.xml" >
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" tools:node="replace" />
</config-file>
但是我一直得到这个错误:
前缀"tools"对于属性"工具:node"与元素类型关联"uses-permission">
有什么好主意吗?提前谢谢你。
我在内置功能方面几乎没有成功,但这个插件很成功:https://github.com/dpa99c/cordova-custom-config
此插件的目的是启用对Cordova/Phonegap CLI不支持的本机平台配置文件的操作。该插件使用hook脚本根据config.xml中定义的自定义数据更新iOS和Android平台的配置文件。
将此文本添加到config.xml顶部的Widget标记
。
& lt;小部件id ="com.mzbapps.serverlife"version ="1.26.1"xmlns ="http://www.w3.org/ns/widgets"xmlns: android ="http://schemas.android.com/apk/res/android"xmlns: cdv ="http://cordova.apache.org/ns/1.0">xmlns:工具="http://schemas.android.com/tools"在
无需任何外部插件即可实现:
<edit-config file="AndroidManifest.xml" target="/manifest" mode="merge">
<manifest xmlns:tools="http://schemas.android.com/tools" />
</edit-config>
https://stackoverflow.com/a/41243851/7138244
在cordova 11下可以正常工作。