Cordova: Error message when building app for Android for the 2nd time

Since quite a while, I am facing a strange phenomenon. If I do a meteor reset and then meteor run android-device, everything works fine. But as soon as I try the meteor run android-device for the second time, I only get this error message:

% "cordova-plugin-file" is required by (cordova-plugin-file-transfer) and cannot be removed (hint: use -f or --force) and cannot be removed (hint: use -f or --force)
=> Errors executing Cordova commands:         
   While removing plugins                     
   from Cordova project:
   Cordova error: Cannot find plugin.xml for plugin 'cordova-plugin-compat'. Please try adding it
   (If the error message contains suggestions for a fix, note that this may not apply to the Meteor
   integration. You can try running again with the --verbose option to help diagnose the issue.)

This can only be resolved by running meteor reset again, but in this case I lose my database contents and all plugins have to be downloaded again - which, in my case, takes very long due to the size of one of the plugins.

Has anybody experienced such problems? Note: I’m still using Meteor 1.2, since one of the plugins is not compatible with Meteor 1.3.

Thanks, Tom

EDIT: Some additional info. Each time this error occurs, the meteor process keeps running in the background and I have to kill -9 it.


Additional info: I now ran the meteor command in verbose mode. This shows this:

Processing mobile-config.js                   
Copying resources for mobile apps             
Writing new config.xml                        
Removing plugins                              
from Cordova project
% Plugin "cordova-plugin-insomnia" is not present in the project. Converting value to "nl.x-services.plugins.insomnia" and trying again.
% Plugin "cordova-plugin-camera" is not present in the project. Converting value to "" and trying again.
% Uninstalling cordova-plugin-statusbar from android
% Uninstalling cordova-plugin-legacy-whitelist from android
% Uninstalling cordova-plugin-globalization from android
% Uninstalling cordova-plugin-file-transfer from android
% Uninstalling cordova-plugin-file from android
% Uninstalling cordova-plugin-device from android
% Uninstalling cordova-plugin-console from android
% Uninstalling com.meteor.cordova-update from android
% Uninstalling com.concats.cordova-plist-patches from android
% Uninstalling nl.x-services.plugins.insomnia from android
% Uninstalling cordova-plugin-splashscreen from android
% Uninstalling phonegap-plugin-push from android
=> Errors executing Cordova commands:         
   While removing plugins                     
   from Cordova project:
   Cordova error: CordovaError: Cannot find plugin.xml for plugin 'cordova-plugin-compat'. Please try adding it again.
   at new PluginInfo
   at PluginInfoProvider.get
   at Array.forEach (native)
   at Object.handlePrepare
   at _fulfilled
   at self.promiseDispatch.done
   at Promise.promise.promiseDispatch
   at flush
   at process._tickCallback (node.js:448:13)
   (If the error message contains suggestions for a fix, note that this may not apply to the Meteor integration. You can try running again with the --verbose
   option to help diagnose the issue.)

It seems as if the uninstall of phonegap-plugin-push fails, which is itself included by the raix:push package. Strange thing is that the initial install works, but not this uninstall. I’m also wondering why Meteor is uninstalling all Cordova plugins each time I rebuild the app, although I did not change anything in the Cordova plugin configuration.

Bump. Just noticed that this affects all my apps, even those who haven’t been touched since weeks. I digged into the problem further and found out that the compat plugin was introduced just recently to allow compatibility between older Cordova versions and the newer Android rights management. Maybe this inadvertently broke something in Meteor? Strange thing is that I did not even update my Meteor version from 1.2 to 1.3. So I can see no good reason why this happens now. Any ideas?

With the assistance of @raix, I think I found the root cause:

Bump. Though my workaround worked fine for months now, I am facing the build problem again after I added the PayPal mobile SDK. Anybody else facing the cordova-plugin-compat build problem?

Have you found a solution to this problem? I am getting a similar error when using Plugman:
plugman install --platform android --project examples/battery/platforms/android/ --plugin .

Cannot find plugin.xml for plugin “plugins”. Please try adding it again.

Yes, it was a problem in Meteor’s build stack, as described here:

Meteor removes all plugins once it detects a change in the set of Cordova plugins used. This process was / is not reliable in Meteor 1.2, and it did not consider plugin dependencies correctly. According to @abernix, the problem cannot be reproduced in Meteor 1.4, so I probably will have to upgrade my Meteor version to resolve it completely.

For the time being, I found a workaround that will only work in Meteor: I added all plugins that are dependencies of other plugins to the cordova-plugins file under the .meteor folder. This prevents Meteor from purging them and thus eliminates the error. But I doubt plugman is using the same mechanism.

I had this similar issue with a local Cordova plugin I was using, and turns out the problem was due to the configuration still remaining in the Cordova configuration, even though I had ran meteor remove cordova:my-cordova-plugin

What I recommend is to remove the plugin and add it back to see if that fixes it (did for me)

First, remove it through meteor:
meteor remove cordova:my-cordova-plugin

Then, goto the .meteor/local/cordova-build/ directory, and run this command to list all cordova plugins:
cordova plugin list

If you see that one listed, run this command to remove it from Cordova:
cordova plugin rm my-cordova-plugin

Then go back to source directory:
I would then run your application to see if it works (to build once first before adding back), and then add it back to the project:

meteor add cordova:my-cordova-plugin

1 Like