Apache Cordova:无法加载资源:服务器响应状态为404(找不到) [英] Apache Cordova: Failed to load resource: the server responded with a status of 404 (Not Found)

查看:1396
本文介绍了Apache Cordova:无法加载资源:服务器响应状态为404(找不到)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在Android模拟器或我的Android设备上运行我的应用程序时,我在所有AJAX请求中遇到以下错误:

 无法加载资源:服务器响应状态为404(找不到)

已尝试所有以下步骤来解决此问题,但它仍然存在。




  • 使用npm将白名单插件安装到项目中。 >
  • 已将< plugin name =cordova-plugin-whitelistversion =1/> 添加到
    config.xml

  • 添加了< uses-permission android:name =android.permission.INTERNET/>

  • 已添加< meta http-equiv =Content-Security-Policycontent =default-src * unsafe-inline';> < meta http-equiv =X-XSS-Protectioncontent =0> c /

  • 添加< access origin = */> < allow-navigation href =*/>
    < allow-intent href =*/> 到config.xml文件。



无论我仍然得到相同的错误。任何想法?



项目编译良好。我在Windows 7上使用Cordova 5.4.0,Android 5.1.1

解决方案

删除应用程序的整个Android部分与:

  cordova平台remove android 

并添加:

  cordova平台添加android 



解决了这个问题,这对我来说还是个谜。



有一些问题,从早期版本的Cordova,使用当前Cordova版本没有得到很好。


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

解决方案

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.

这篇关于Apache Cordova:无法加载资源:服务器响应状态为404(找不到)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆