<config-file>
オーバーライドに非常に便利に見えます... 残念ながら、これはPhoneGapのみの機能のようです。Cordova の場合、おそらくフックを使用する必要があります。
良い例はここにあります
スクリプトを修正して、必要な機能を追加しました (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" />
それが役に立てば幸い