I'm sure the reason you can still use the plugin is because you either edited the wrong config.xml or you didn't run the cordova command-line tools to propagate your changes to the correct config.xml file, which is actually used by the application.
There are several config.xml files in different places in the Cordova 3.x project. I will try to give you an overview of the different file locations and how you should interact with them. Keep in mind that this happens when you use the CLI ( Command Line Interface ). I created this directory structure by typing:
cordova create {MyApp} cordova platform add android ios cordova plugin add org.apache.cordova.network-information
Or before Cordoba 3.1, replace the last line as follows:
cordova plugin add https:
If you use only platform-level shell scripts to create the application (the “old” way we did in Cordova 2.X), you can usually use the same workflow, but it needs to Use Plugman to manage the plugins . (We are in the process of documenting these two different “workflows.")
Firstly, when creating an application with cordova create MyApp it will create an empty project structure as follows:
/myApp/ /www/
You must make all your changes to the files in /www/ , which is the cross-platform source code. Everything in this folder will usually be copied and distributed to the www platform using the command line tools (be it /assets/www for Android or just /www/ for iOS). Thus, you only need one source folder for your application - this is the folder that you must have when managing versions. Any changes to the configuration of the application as a whole that you want should be made to the config.xml file located in this place; later, when you use the tools, this config.xml file will be copied (and sometimes modified with configuration information on the platform) to the appropriate location for each application, for example /platforms/android/res/xml/config.xml (for android) or /platforms/ios/AppName/config.xml (for iOS).
Suppose you want to add an acceleration plugin by typing cordova plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-network-information.git . If you run diff after this command, you will see that the following files have been changed or added:
plugins / org.apache.cordova.network-information / - This new folder contains all the meta-information and plug-in code, including web and native code, for each supported platform
/android.json plugins and /ios.json plugins - Both of these files have now been edited to contain a link to the network information plugin. Here you will see the JSON configuration bit. When you add more plugins, this file will constantly grow to reference all of them. This file tells the command line tools which code to replace and in which files. For example, after adding the plugin cordova-plugin-network-info you will see this in /plugins/android.json :
{ "prepare_queue": { "installed": [], "uninstalled": [] }, "config_munge": { "res/xml/config.xml": { "/*": { "<feature name=\"NetworkStatus\"><param name=\"android-package\" value=\"org.apache.cordova.networkinformation.NetworkManager\" /></feature>": 1 } }, "AndroidManifest.xml": { "/*": { "<uses-permission android:name=\"android.permission.ACCESS_NETWORK_STATE\" />": 1 } } }, "installed_plugins": { "org.apache.cordova.network-information": { "PACKAGE_NAME": "io.cordova.hellocordova" } }, "dependent_plugins": {} }
This tells the scripts to write the function name in res/xml/config.xml (again, for iOS it will be different, since the application-level configuration file is in a different location on iOS!), And also tells it to write android.permission.ACCESS_NETWORK_STATE to AndroidManifest.xml (you will not find anything similar on iOS, since no permissions are required.) (By the way, what is written to each of these json files is defined in the plugin plugin.xml file.)
platforms /Android/AndroidManifest.xml - CLI tools have taken care to add any permission defined in the plugin xml file to AndoridManifest. Yes, this happens when you do the cordova plugin add . These permissions are directly copied from the plugins / android.json file. These permissions are also removed when you have the 'rm' plugin. However, editing these files is done intelligently, as you can add custom things to AndroidManifest.xml and they will be saved.
platforms / Android / assets / WWW / cordova_plugins.js - This file is similar to the html resources that will make up your final application - these resources (almost nothing in / platform /) should not be edited by you because they will be replaced by CLI tools rather often. This file is used by Cordova at run time to load the added plugin code; he also takes care of matching JavaScript namespaces with actual files (this is the declaration of "clobbers"). For example, I see:
{ "file": "plugins/org.apache.cordova.network-information/www/network.js", "id": "org.apache.cordova.network-information.network", "clobbers": [ "navigator.connection", "navigator.network.connection" ] }
this means that in your application code navigator.connection and navigator.network.connection code contained in plugins/org.apache.cordova.network-information/www/network.js will be displayed.
platforms /Android/RES/XML/config.xml - This is the platform level config.xml file for Android. This file is created by the CLI tools. Most of the information you write at your top level config.xml (/MyApp/www/config.xml) will be copied here, but not all (and there are some additional things, I'm not quite sure where the additional material comes from.) This is the file that Android reads when it launches your application, and it needs to check your configuration data. For example, Cordoba Android code will use this to see which plugins are installed and which native classes map to those namespaces. I think the only way you could edit this is to use / merges / folder, which I mentioned above.
platforms / iOS / {AppName} .xcodeprojcj / project.pbxproj - iOS equivalent of AndroidManifest.xml
platforms / iOS / {AppName} /config.xml - This is the config.xml configuration file on the iOS platform. See how this happens elsewhere than on Android? (for example, not in /res/xml/config.xml?) This file is automatically updated by the CLI, and you should not touch it.
platforms / iOS / WWW / cordova_plugins.js - The same file exists on Android (but in a different place) and has the same goal: to help Cordoba load your plugins at runtime when someone uses the application
I think that pretty much all the files and folders that are used in the cordova project are described.
Hopefully now you will see that you should actually edit the /www/config.xml file. This file will be used to create the /platforms/android/res/xml/config.xml and /platforms/ios/{AppName}/config.xml that Cordona uses when launching the packaged application. Parts of this file will be used to edit the AndroidManifest.xml and project.pbxprojc files (for Android and iOS, respectively.)
This explains why you could still use the accelerometer in your application even after deleting the <feature name="Accelerometer"> lines - they were simply rewritten to the platform level config.xml from the main application config.xml
I think that it remains only to find out how you can edit the configuration files on the platform; for example, how can you edit the AndroidManifest.xml file? Well, it turns out that you can simply edit the /platforms/android/AndroidManifest.xml file directly - the CLI is smart enough not to erase your settings when it automatically adds or removes the permissions of the plugin. Therefore, for some reason you need to support a lower version of Android than Cordoba supports, you can just change the object and it will be saved, although your calls are cordova plugin add|rm {id} .
I hope this clarifies the situation, feel free to ask more questions!