1

Every plugin I try to install throws an error saying it can't find the manifest. And it's true, the file isn't there. I am trying to upgrade off 6.4 as 6.4 doesn't seem to support 64bit CPUs on Android without making manual changes to the build manifest.

Failed to install 'cordova-plugin-geolocation': Error: ENOENT: no such file or directory, open 'C:\...\platforms\android\AndroidManifest.xml'

Failed to install 'cordova-plugin-file': Error: ENOENT: no such file or directory, open 'C:\..\platforms\android\AndroidManifest.xml'

Failed to install 'cordova-plugin-google-analytics': Error: ENOENT: no such file or directory, open 'C:\...\platforms\android\AndroidManifest.xml'

Failed to install 'cordova-plugin-inappbrowser': Error: ENOENT: no such file or directory, open 'C:\...\platforms\android\AndroidManifest.xml'

Failed to install 'cordova-plugin-whitelist': Error: ENOENT: no such file or directory, open 'C:\...\platforms\android\AndroidManifest.xml'

Failed to install 'cordova-plugin-network-information': Error: ENOENT: no such file or directory, open 'C:\...\platforms\android\AndroidManifest.xml'

Failed to install 'cordova-sqlite-storage': Error: ENOENT: no such file or directory, open 'C:\...\platforms\android\AndroidManifest.xml'

Failed to install 'cordova-plugin-android-permissions': Error: ENOENT: no such file or directory, open 'C:\...\platforms\android\AndroidManifest.xml'

Failed to install 'cordova-plugin-statusbar': Error: ENOENT: no such file or directory, open 'C:\...\platforms\android\AndroidManifest.xml'

Failed to install 'cordova-plugin-device': Error: ENOENT: no such file or directory, open 'C:\...\platforms\android\AndroidManifest.xml'

Failed to install 'cordova-plugin-image-picker': Error: ENOENT: no such file or directory, open 'C:\...\platforms\android\AndroidManifest.xml'

How do I solve these errors?

Trevor
  • 2,792
  • 1
  • 30
  • 43
  • see my answer https://stackoverflow.com/questions/47926796/cordova-does-not-create-androidmanifest-xml/47927193#47927193 – jcesarmobile Jun 29 '18 at 11:53
  • Trouble is these are mostly apache provided plugins. Very troubling if they aren't updated by the people that updated cordova – Trevor Jun 29 '18 at 13:23
  • You didn't read my updated answer or you didn't understand it. All the apache provided plugins work fine on cordova-android 7.1.0. The problem is one of the 3rd party plugins using source-file tag for copying images and making cordova crazy. One of them is `cordova-plugin-image-picker`, remove that, remove cordova-android and add it again and see what happens. – jcesarmobile Jun 29 '18 at 13:59
  • @jcesarmobile Yes image picker was bad. Thank you – Trevor Jun 29 '18 at 14:06
  • @TrevorD - if you are still looking for a proper `cordova-plugin-image-picker` plugin, you can use this one https://github.com/Telerik-Verified-Plugins/ImagePicker. I believe it is basically the same, but it has the properly adjusted tags. – Angel Todorov Aug 08 '18 at 10:53
  • @AngelTodorov Thank you. I will start watching that one and https://github.com/DmcSDK/cordova-plugin-mediaPicker – Trevor Aug 14 '18 at 17:51

3 Answers3

9

Got the answer, the amazing community made a script to patch it.

Create a script in your scripts folder called

patch-android-studio-check.js

Put this inside it

/**
 * This hook overrides a function check at runtime. Currently, cordova-android 7+ incorrectly detects that we are using
 * an eclipse style project. This causes a lot of plugins to fail at install time due to paths actually being setup
 * for an Android Studio project. Some plugins choose to install things into 'platforms/android/libs' which makes
 * this original function assume it is an ecplise project.
 */
module.exports = function(context) {
  if (context.opts.cordova.platforms.indexOf('android') < 0) {
    return;
  }

  const path = context.requireCordovaModule('path');
  const androidStudioPath = path.join(context.opts.projectRoot, 'platforms/android/cordova/lib/AndroidStudio');
  const androidStudio = context.requireCordovaModule(androidStudioPath);
  androidStudio.isAndroidStudioProject = function() {  return true; };
};

Then add these hooks

<platform name="android">
   <hook src="scripts/patch-android-studio-check.js" type="before_plugin_install" />
   <hook src="scripts/patch-android-studio-check.js" type="before_plugin_install" />
   <hook src="scripts/patch-android-studio-check.js" type="before_plugin_add" />
   <hook src="scripts/patch-android-studio-check.js" type="before_build" />
   <hook src="scripts/patch-android-studio-check.js" type="before_run" />
   <hook src="scripts/patch-android-studio-check.js" type="before_plugin_rm" />
</platform>

Next, delete your plugins and platforms folder. Then run cordova platform add android and this will recreate the platform and add the plugins correctly.

Second part is don't use the image picker plugin.

Update March 2019 - As of Cordova Android verison 8, this appears to be no longer required and will actually cause problems.

Trevor
  • 2,792
  • 1
  • 30
  • 43
2

According to the docs (cordova android 7, file path of AndroidManifest.xmlhas changed. So you have to update all of your plugins to a version that support android 7 !

Djiggy
  • 602
  • 6
  • 20
0

On your config.xml file just under

<platform name="android">

Add this line

<resource-file src="platforms/android/app/src/main/AndroidManifest.xml" target="AndroidManifest.xml" />