How can we add android:largeHeap to true in manifest file using plugin.xml file in android phonegap
A solution that worked for us was doing this with a Cordova/PhoneGap Hook.
Create a hook at the following path
{app-root}/hooks/after_prepare directory/010-update-android-manifest.js
Important to make this file executable
chmod +x 010-update-android-manifest.js
#!/usr/bin/env node
var fs = require('fs');
var async = require('async');
var exec = require('child_process').exec;
var path = require('path');
var root = process.argv[2];
var androidManifest = path.join(root, 'platforms/android/AndroidManifest.xml');
fs.exists(path.join(root, 'platforms/android'), function(exists) {
if(!exists) return;
fs.readFile(androidManifest, 'utf8', function(err, data) {
if(err) throw err;
var lines = data.split('\n');
var searchingFor = '<application android:hardwareAccelerated="true"';
var newManifest = [];
var largeHeap = 'android:largeHeap="true"';
lines.forEach(function(line) {
if(line.trim().indexOf(searchingFor) != -1 && line.trim().indexOf(largeHeap) == -1) {
newManifest.push(line.replace(/\>$/, ' ') + largeHeap + ">");
} else {
newManifest.push(line);
}
});
fs.writeFileSync(androidManifest, newManifest.join('\n'));
});
});
This will append android:largeHeap="true" to the application tag.
Build your app
cordova build
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With