updateMultidexManifest.js 887 B

12345678910111213141516171819
  1. module.exports = function(ctx) {
  2. var fs = ctx.requireCordovaModule('fs'),
  3. path = ctx.requireCordovaModule('path'),
  4. xml = ctx.requireCordovaModule('cordova-common').xmlHelpers;
  5. var manifestPath = path.join(ctx.opts.projectRoot, 'platforms/android/AndroidManifest.xml');
  6. var doc = xml.parseElementtreeSync(manifestPath);
  7. if (doc.getroot().tag !== 'manifest') {
  8. throw new Error(manifestPath + ' has incorrect root node name (expected "manifest")');
  9. }
  10. //adds the tools namespace to the root node
  11. // doc.getroot().attrib['xmlns:tools'] = 'http://schemas.android.com/tools';
  12. //add tools:replace in the application node
  13. doc.getroot().find('./application').attrib['android:name'] = 'android.support.multidex.MultiDexApplication';
  14. //write the manifest file
  15. fs.writeFileSync(manifestPath, doc.write({indent: 4}), 'utf-8');
  16. };