我今天升级到最新的Cordova - 5.4.1.iOS上的应用程序保持正常工作,但不适用于Android.所有请求都返回404错误,所以我深入研究了主题,发现我需要"cordova-plugin-whitelist".我安装了它并添加了
<meta http-equiv="Content-Security-Policy" content="default-src * 'unsafe-inline' 'unsafe-eval'">
到index.html的头文件以及<access origin="*" /><allow-navigation href="*"/>config.xml
现在每个对外部世界的请求都返回"net :: ERR_NAME_NOT_RESOLVED"
在AndroidManifest.xml中我有这两行,所以我想这不是Internet访问的问题.
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
我经历了很多与cordova-plugin-whitelist有关的问题,但似乎没什么用
我的config.xml```
<?xml version='1.0' encoding='utf-8'?>
<widget id="app" version="1.1.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>app</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" />
<allow-navigation href="*" />
<platform name="ios">...splash screens and icons</platform>
<platform name="android">...splash screens and icons</platform>
<icon src="resources/android/icon/drawable-xhdpi-icon.png" />
<preference name="SplashScreen" value="screen" />
<preference …Run Code Online (Sandbox Code Playgroud)