ERROR(404 Not Found) whitelist rejection for Android

PhoneGap Feb 29, 2016

Hey Guys,

I am came up with another issue while building an app with PhoneGap wherein my application running on IOS devices were able to contact to server but getting '404 not found' error with Android devices. It was initially bit confusing as same piece of code works for android & IOS.

With little investigation, I found that after cordova 4.0, whitelist policy has been changed for Android devices and in order to run these callouts, We have to whitelist the domains with cordova-plugin-whitelist

Now, you can have to add two things in your code.

  1. Add following code to config.xml file.

     <allow-intent href="*"/>
     <allow-navigation href="*"/>
    
  2. Add following meta tag to index.html file.

     <!-- meta tag as per cordova whitelist plugin -->
     <meta http-equiv="Content-Security-Policy" content="default-src *; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'">
    

    Note: There are various meta tags provided by this plugin to apply as per your need. Please visit documentation to know more.

Related post : Error whitelist rejection before cordova 4.0

Hope this helps, happy coding!

Related Tags:

PhoneGap   Android