当我在 Android 模拟器或我的 Android 设备上运行我的应用程序时,我在所有 AJAX 请求中遇到以下错误:
Failed to load resource: the server responded with a status of 404 (Not Found)
我已经尝试了以下所有步骤来解决这个问题,但它仍然存在。
- 使用 npm 将白名单插件安装到项目中。
- 已添加
<plugin name="cordova-plugin-whitelist" version="1" />
至 配置.xml。 - 已添加
<uses-permission android:name="android.permission.INTERNET" />
到 platforms\android\AndroidManifest.xml。 - 已添加
<meta http-equiv="Content-Security-Policy" content="default-src * 'unsafe-inline';">
和<meta http-equiv="X-XSS-Protection" content="0">
到<head>
的 www/index.html 文件。 - 已添加
<access origin="*" />
,<allow-navigation href="*" />
和<allow-intent href="*" />
到 config.xml 文件。
无论如何,我仍然会遇到同样的错误。有什么想法吗?
项目编译正常。我在 Windows 7 上,使用 Cordova 5.4.0,Android 5.1.1
最佳答案
删除应用程序的整个 Android 部分:
cordova platform remove android
并再次添加:
cordova platform add android
解决了这个问题,这对我来说仍然是个谜。
也许早期版本的 Cordova 遗留了一些错误,这些错误与当前的 Cordova 版本不兼容。
关于android - Apache Cordova : Failed to load resource: the server responded with a status of 404 (Not Found),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33861413/