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

编程入门 行业动态 更新时间:2024-10-11 09:23:10
本文介绍了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(找不到)

本文发布于:2023-08-03 04:37:27,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1284015.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:找不到   加载   状态   服务器   资源

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!