<config-file>
看起來超有用的重寫....唉似乎這是一個PhoneGap唯一的功能。對於科爾多瓦,你可能需要使用掛鉤。
一個很好的例子可以發現HERE
伊夫修改腳本中加入我需要的功能(我需要GPS和攝像頭是可選功能)。
module.exports = function (context) {
var fs = context.requireCordovaModule('fs'),
path = context.requireCordovaModule('path');
var platformRoot = path.join(context.opts.projectRoot, 'platforms/android');
var manifestFile = path.join(platformRoot, 'AndroidManifest.xml');
if (fs.existsSync(manifestFile)) {
fs.readFile(manifestFile, 'utf8', function (err, data) {
if (err) {
throw new Error('Unable to find AndroidManifest.xml: ' + err);
}
var insertAt = data.indexOf("</manifest>");
var optionalFeatures = "<uses-feature android:name=\"android.hardware.LOCATION\" android:required=\"false\"/><uses-feature android:name=\"android.hardware.location.GPS\" android:required=\"false\"/><uses-feature android:name=\"android.hardware.camera\" android:required=\"false\"/><uses-feature android:name=\"android.hardware.camera.autofocus\" android:required=\"false\"/>";
var result = data.slice(0, insertAt) + optionalFeatures + data.slice(insertAt);
fs.writeFile(manifestFile, result, 'utf8', function (err) {
if (err) throw new Error('Unable to write into AndroidManifest.xml: ' + err);
})
});
}
};
然後設置鉤config.xml中
<hook type="after_build" src="scripts/afterBuild.js" />
希望它能幫助[Android的PhoneGap的配置XML用戶許可(的
可能重複http://stackoverflow.com/questions/26440655/ android-phonegap-config-xml-user-permission) – 2015-04-03 14:49:19
感謝@JamesBaxter的關注。我在問這個問題之前檢查了點,但它沒有幫助,因爲我想讓它們不是必需的,而不是讓它們成爲應用程序所需的東西......或者我錯過了一些關於它的信息 – borna 2015-04-03 14:53:23
對不起,我的錯不能正確理解 - 我已經提出了一個更清晰的問題,以防其他人可以幫助 – 2015-04-03 14:58:16