Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Apache Cordova: Failed to load resource: the server responded with a status of 404 (Not Found)

When I run my application either in the Android emulator or on my Android device, I get he following error on all AJAX requests:

Failed to load resource: the server responded with a status of 404 (Not Found)

I have tried all the following steps to solve this problem, but it persists.

  • Installed the whitelist plugin to the project using npm.
  • Added <plugin name="cordova-plugin-whitelist" version="1" /> to config.xml.
  • Added <uses-permission android:name="android.permission.INTERNET" /> to platforms\android\AndroidManifest.xml.
  • Added <meta http-equiv="Content-Security-Policy" content="default-src * 'unsafe-inline';"> and <meta http-equiv="X-XSS-Protection" content="0"> to the <head> of www/index.html file.
  • Added <access origin="*" />, <allow-navigation href="*" /> and <allow-intent href="*" /> to the config.xml file.

Regardless I still get the same errors. Any ideas?

The project compiles fine. I'm on Windows 7, using Cordova 5.4.0, Android 5.1.1

like image 604
Kaspi Avatar asked Nov 22 '15 23:11

Kaspi


1 Answers

Removing the whole Android part of the application with:

cordova platform remove android

and adding it again with:

cordova platform add android

solved the problem, which is still a mystery to me.

Perhaps there was something wrong left from the earlier versions of Cordova that wasn't getting on well with the current Cordova version.

like image 114
Kaspi Avatar answered Oct 13 '22 17:10

Kaspi