Phonegap Android From 3.7.0 To 4.0.2 Cross-domain Xhr 404's
Solution 1:
When you switch to cli-5.1.1
, you will switch to the 4.0.x
version of Android. As @laughingpine has pointed out in a comment, the white-listing mechanism has been changed. Earlier, you could use <access origin="*" />
to obtain access to all domains. This no longer applies.
Now you need cordova-plugin-whitelist
(https://github.com/apache/cordova-plugin-whitelist). Please refer to the documentation for the specifics. The rough equivalent of the earlier wildcard is <allow-navigation href="*" />
, which is the new mechanism.
To build under PhoneGap Build (hence forth referred to as PGB), you will need to add the plugin. Since the plugin is available under npm
(the Node Package Manager), you can find the latest version under the cordova-plugin-whitelist
name (https://www.npmjs.com/package/cordova-plugin-whitelist). PGB can build a plugin from npm
with the following notation:
<gap:plugin name="cordova-plugin-whitelist" version="1.0.0"source="npm" />
Now PGB will build correctly and your whitelist works as before.
Solution 2:
For anyone else who had a legacy app built in phonegap but updated their build process to use a recent version of cordova, Roel's answer needs a slight tweak.
old config.xml
<widget... /><name>Legacy App built in phonegap</name><accessorigin="*" /></widget>
new config.xml
for cordova
<widget... /><name>Legacy App built in phonegap</name><pluginname="cordova-plugin-whitelist"version="1" /><allow-navigationhref="*" /></widget>
If you get an XML: unbound prefix
exception being thrown, this may help.
Post a Comment for "Phonegap Android From 3.7.0 To 4.0.2 Cross-domain Xhr 404's"