Android Cordova 8.0.0 Ajax错误
我知道,关于这一点,还有更多的话题,我已经看完了,但没有任何效果,所以我要写一篇新的: 我正在尝试在Android平台上创建AJAX读取请求(但iOS也是计划中的)。 每次尝试都会有一些错误 我所做的: 1)我安装了cordova白名单插件(随cordova安装而来) 2)我在config.xml中有各种定义,每种类型的最后一个定义(访问、允许意图、允许导航)都设置为*以进行测试 3)我(我认为)在\platforms\android\app\src\main\AndroidManifest.xml中有所有允许访问的定义 4)我尝试了各种html元标记 5)我尝试过removig并重新添加android平台 6)我已尝试重新启动移动设备 7)我试过移动数据、wifi,甚至两者都试过 8)ajax请求是通过http而不是https进行的 9)ajax请求位于Android Cordova 8.0.0 Ajax错误,android,ajax,cordova,Android,Ajax,Cordova,我知道,关于这一点,还有更多的话题,我已经看完了,但没有任何效果,所以我要写一篇新的: 我正在尝试在Android平台上创建AJAX读取请求(但iOS也是计划中的)。 每次尝试都会有一些错误 我所做的: 1)我安装了cordova白名单插件(随cordova安装而来) 2)我在config.xml中有各种定义,每种类型的最后一个定义(访问、允许意图、允许导航)都设置为*以进行测试 3)我(我认为)在\platforms\android\app\src\main\AndroidManifest.x
$(文档)中链接的testAjax.js中。就绪(…)
关于theese元标记:
<meta http-equiv="Content-Security-Policy" content="default-src 'self' 'unsafe-inline' *">
得到
获取与上面相同的值
<!-- Good default declaration:
* gap: is required only on iOS (when using UIWebView) and is needed for JS->native communication
* https://ssl.gstatic.com is required only on Android and is needed for TalkBack to function properly
* Disables use of eval() and inline scripts in order to mitigate risk of XSS vulnerabilities. To change this:
* Enable inline JS: add 'unsafe-inline' to default-src
* Enable eval(): add 'unsafe-eval' to default-src
-->
<meta http-equiv="Content-Security-Policy" content="default-src 'unsafe-inline' 'self' data: gap: https://ssl.gstatic.com; style-src 'self' 'unsafe-inline'; media-src *">
我试了很多次,但总有三个错误中的一个
另外,下面是我的config.xml:
<?xml version='1.0' encoding='utf-8'?>
<widget id="com.TG.app" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>TG</name>
<description>
A sample Apache Cordova application that responds to the deviceready event.
</description>
<author email="dev@cordova.apache.org" href="http://cordova.io">
Apache Cordova Team
</author>
<content src="index.html" />
<access origin="http://mytestdomain.com" />
<access origin="http://mytestdomain.com/*" />
<access origin="*" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<allow-intent href="tel:*" />
<allow-intent href="sms:*" />
<allow-intent href="mailto:*" />
<allow-intent href="geo:*" />
<allow-intent href="gap:*" />
<allow-intent href="*" />
<allow-navigation href="http://*/*" />
<allow-navigation href="https://*/*" />
<allow-navigation href="data:*" />
<allow-navigation href="http://mytestdomain.com" />
<allow-navigation href="*" />
<platform name="android">
<allow-intent href="market:*" />
</platform>
<platform name="ios">
<allow-intent href="itms:*" />
<allow-intent href="itms-apps:*" />
</platform>
<plugin name="cordova-plugin-googlemaps" spec="^2.2.5">
<variable name="API_KEY_FOR_ANDROID" value="mykey" />
<variable name="API_KEY_FOR_IOS" value="mykey" />
<variable name="PLAY_SERVICES_VERSION" value="11.8.0" />
<variable name="ANDROID_SUPPORT_V4_VERSION" value="24.1.0" />
</plugin>
<preference name="Orientation" value="portrait" />
<plugin name="cordova-plugin-whitelist" spec="^1.3.3" />
<engine name="browser" spec="^5.0.3" />
<engine name="android" spec="^7.0.0" />
</widget>
甘油三酯
响应deviceready事件的Apache Cordova应用程序示例。
阿帕奇科尔多瓦团队
在Android清单中,我有
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
有什么想法吗,这里出了什么问题,以及如何让它发挥作用?(即使一切都是开放的,安全在这里也不是问题,我只需要让它以任何方式发挥作用)
提前感谢:)好的,我找到了解决方案。 关键是从默认src中删除“self”关键字。 所以这是可行的:
<meta http-equiv="Content-Security-Policy" content="default-src 'unsafe-inline' 'unsafe-eval' *">
希望他们能尽快更新cordova文档,因为这没有涵盖,并且遵循他们建议的所有元标记,就像遵循StackOverflow上的所有指南一样,会导致失败,因为每个人都有“self”关键字
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<meta http-equiv="Content-Security-Policy" content="default-src 'unsafe-inline' 'unsafe-eval' *">