Cordova项目config.xml添加android权限
最近在开发cordova项目,安卓APP需要调用照相机和系统相册,在添加安卓权限的时候,总是报错。
以下是部分config.xml代码
<platform name="android"> <name>项目名称</name> <allow-intent href="market:*" /> <icon density="ldpi" src="res/icon/android/icon_48.png" /> <icon density="mdpi" src="res/icon/android/icon_48.png" /> <icon density="hdpi" src="res/icon/android/icon_72.png" /> <icon density="xhdpi" src="res/icon/android/icon_96.png" /> <icon density="xxhdpi" src="res/icon/android/icon_144.png" /> <icon density="xxxhdpi" src="res/icon/android/icon_192.png" /> <splash density="land-hdpi" src="res/screen/android/splash-land-hdpi.png" /> <splash density="land-ldpi" src="res/screen/android/splash-land-ldpi.png" /> <splash density="land-mdpi" src="res/screen/android/splash-land-mdpi.png" /> <splash density="land-xhdpi" src="res/screen/android/splash-land-xhdpi.png" /> <splash density="land-xxhdpi" src="res/screen/android/splash-land-xxhdpi.png" /> <splash density="port-hdpi" src="res/screen/android/splash-port-hdpi.png" /> <splash density="port-ldpi" src="res/screen/android/splash-port-ldpi.png" /> <splash density="port-mdpi" src="res/screen/android/splash-port-mdpi.png" /> <splash density="port-xhdpi" src="res/screen/android/splash-port-xhdpi.png" /> <splash density="port-xxhdpi" src="res/screen/android/splash-port-xxhdpi.png" /> <config-file parent="/*" target="AndroidManifest.xml"> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.CAMERA" /> </config-file> </platform>
其中权限部分为:
<config-file parent="/*" target="AndroidManifest.xml"> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.CAMERA" /> </config-file>
编译的时候总是报错:
/platforms/android/build/intermediates/res/merged/debug/xml/config.xml:79: error: Error parsing XML: unbound prefix
解决:
在widget标签引入xmlns:android="http://schemas.android.com/apk/res/android"
<widget id="com.demo.myapp" version="1.1.0.0" 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">