So I'm building a cordova app and it utilize the Facebook Login plugin (but the question appplies to any other plugin as well). Sometimes I want to change the Facebook APP_ID that the plugin connects to, so i assumed the following flow would work:
First. Change the variables in config.xml with the new Facebook ID
<plugin name="cordova-plugin-facebook4" spec="~1.7.1">
<variable name="APP_ID" value="1728167004731036" />
<variable name="APP_NAME" value="QuickShop Sandbox" />
</plugin>
Second. Do a cordova prepare
followed by a cordova build --release android
However the following files keeps to have the old variables that were specified in fetch.json
when installing the plugin.
platforms/android/android.json
platforms/android/res/values/facebookconnect.xml
platforms/android/build/build/intermediates/incremental/mergeReleaseResources/merger.xml
platforms/android/build/intermediates/res/merged/values/values.xml
Does the variables in fetch.json
overrides the ones in config.xml
, how can I do the opposite. What the best way to instruct Cordova to always use the plugin variables in config.xml
First to explain few things, You need not have to explicitly add the plugin in config.xml as its not a mandate and also if required you can add it automatically using --save
option rather than doing it manually. For example,
cordova plugin add cordova-plugin-camera --save
This command adds the plugin and adds the entry automatically to config.xml
Also fetch.json is a file that tracks installed plugins, their origin and revision like npm package.json This file is updated on cordova add/remove plugins. When we cordova prepare
, cordova reads plugin list from plugins/ios.json (in case of ios), get the plugin infos from plugins/fetch.json and try to find the plugin locally.
So if gotta instruct cordova to always use the plugin variables in config.xml
, follow steps below:
Define plugins dependencies in config.xml (use --save
option preferably)
Remove platforms and contents inside plugins folder
Run cordova platform add PLATFORM_NAME
command
This ensures that plugin info is config.xml is always honoured