How to add android: largeHeap = "true" in the manifest file using the Plugin.xml file in the phonegap plugin

How can we add android: largeHeap to true in the manifest file using the plugin.xml file in the Android phonebook.

+6
source share
2 answers

The solution that worked for us did this with the Cordova / PhoneGap Hook.

Create a hook along the following path

{app-root}/hooks/after_prepare directory/010-update-android-manifest.js

It is 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 add the android application tag : largeHeap = "true" .

Create application

cordova build

+11
source

Using the Phonegap assembly, you can use the following

 <gap:config-file platform="android" parent="/manifest"> <application android:largeHeap="true"></application> </gap:config-file> 

This requires you to add android xmlnamespace to the widget element

 xmlns:android="http://schemas.android.com/apk/res/android" 

(for more information see http://phonegap.com/blog/2014/01/30/customizing-your-android-manifest-and-ios-property-list-on-phonegap-build/ )

+1
source

Source: https://habr.com/ru/post/984539/


All Articles