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


#1

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                     
   com.concats.cordova-plist-patches,com.meteor.cordova-update,com.percolatestudio.cordova.safereload,com.tokbox.cordova.opentok,cordova-plugin-compat,cordova-plugin-console,cordova-plugin-device,cordova-plugin-file,cordova-plugin-file-transfer,cordova-plugin-globalization,cordova-plugin-legacy-whitelist,cordova-plugin-splashscreen,cordova-plugin-statusbar,cordova-plugin-insomnia,cordova-plugin-camera,phonegap-plugin-push
   from Cordova project:
   Cordova error: Cannot find plugin.xml for plugin 'cordova-plugin-compat'. Please try adding it
   again.
   (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.


Cordova build time?
#2

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                              
com.concats.cordova-plist-patches,com.meteor.cordova-update,cordova-plugin-console,cordova-plugin-device,cordova-plugin-file,cordova-plugin-file-transfer,cordova-plugin-globalization,cordova-plugin-legacy-whitelist,cordova-plugin-splashscreen,cordova-plugin-statusbar,cordova-plugin-insomnia,cordova-plugin-camera,phonegap-plugin-push
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 "org.apache.cordova.camera" 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                     
   com.concats.cordova-plist-patches,com.meteor.cordova-update,cordova-plugin-console,cordova-plugin-device,cordova-plugin-file,cordova-plugin-file-transfer,cordova-plugin-globalization,cordova-plugin-legacy-whitelist,cordova-plugin-splashscreen,cordova-plugin-statusbar,cordova-plugin-insomnia,cordova-plugin-camera,phonegap-plugin-push
   from Cordova project:
   Cordova error: CordovaError: Cannot find plugin.xml for plugin 'cordova-plugin-compat'. Please try adding it again.
   at new PluginInfo
   (/Users/waldgeist/.meteor/packages/meteor-tool/.1.1.10.195lp5z++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/dev_bundle/lib/node_modules/cordova-lib/src/PluginInfo.js:329:15)
   at PluginInfoProvider.get
   (/Users/waldgeist/.meteor/packages/meteor-tool/.1.1.10.195lp5z++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/dev_bundle/lib/node_modules/cordova-lib/src/PluginInfoProvider.js:35:32)
   at
   /Users/waldgeist/.meteor/packages/meteor-tool/.1.1.10.195lp5z++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/dev_bundle/lib/node_modules/cordova-lib/src/plugman/prepare.js:80:45
   at Array.forEach (native)
   at Object.handlePrepare
   (/Users/waldgeist/.meteor/packages/meteor-tool/.1.1.10.195lp5z++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/dev_bundle/lib/node_modules/cordova-lib/src/plugman/prepare.js:78:24)
   at
   /Users/waldgeist/.meteor/packages/meteor-tool/.1.1.10.195lp5z++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/dev_bundle/lib/node_modules/cordova-lib/src/plugman/uninstall.js:341:28
   at _fulfilled
   (/Users/waldgeist/.meteor/packages/meteor-tool/.1.1.10.195lp5z++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/dev_bundle/lib/node_modules/q/q.js:787:54)
   at self.promiseDispatch.done
   (/Users/waldgeist/.meteor/packages/meteor-tool/.1.1.10.195lp5z++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/dev_bundle/lib/node_modules/q/q.js:816:30)
   at Promise.promise.promiseDispatch
   (/Users/waldgeist/.meteor/packages/meteor-tool/.1.1.10.195lp5z++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/dev_bundle/lib/node_modules/q/q.js:749:13)
   at
   /Users/waldgeist/.meteor/packages/meteor-tool/.1.1.10.195lp5z++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/dev_bundle/lib/node_modules/q/q.js:810:14
   at flush
   (/Users/waldgeist/.meteor/packages/meteor-tool/.1.1.10.195lp5z++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/dev_bundle/lib/node_modules/q/q.js:108:17)
   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.)
                                              
ExitWithCode:1

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.


#3

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?


#4

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


#5

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?


#6

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 .

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


#7

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.


#8

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