Issue
I upgraded today to the newest Cordova - 5.4.1. App on iOS kept working just fine but not on Android. All requests were returning 404 error, so I dig into the topic and found out that I need "cordova-plugin-whitelist". I installed it and added
<meta http-equiv="Content-Security-Policy" content="default-src * 'unsafe-inline' 'unsafe-eval'">
to the header of index.html as well as <access origin="*" /><allow-navigation href="*"/>
to config.xml
and now every request to external world is returning "net::ERR_NAME_NOT_RESOLVED"
In AndroidManifest.xml I have those two lines so I guess it's not a problem with Internet access.
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
I went through many questions on SO related to cordova-plugin-whitelist but nothing seems to work
My 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="[email protected]" 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 name="SplashScreenDelay" value="3000" />
<preference name="Orientation" value="default" />
<feature name="phonegap-parse-plugin">
<param name="id" value="org.apache.cordova.core.parseplugin" />
<param name="url" value="https://github.com/fastrde/phonegap-parse-plugin" />
</feature>
<feature name="Insomnia (prevent screen sleep)">
<param name="id" value="nl.x-services.plugins.insomnia" />
<param name="url" value="https://github.com/EddyVerbruggen/Insomnia-PhoneGap-Plugin.git" />
</feature>
<feature name="Toast">
<param name="id" value="cordova-plugin-x-toast" />
<param name="url" value="https://github.com/EddyVerbruggen/Toast-PhoneGap-Plugin.git" />
</feature>
<feature name="Cordova SMS Plugin">
<param name="id" value="com.cordova.plugins.sms" />
<param name="url" value="https://github.com/cordova-sms/cordova-sms-plugin.git" />
</feature>
<feature name="OpenTokCordovaPlugin">
<param name="id" value="com.tokbox.cordova.opentok" />
<param name="url" value="https://github.com/doxyme/cordova-plugin-opentok" />
</feature>
</widget>
```
Solution
I have no idea what the issue was but restarting device resolved it. Nothing related to the app, just the phone had difficulties with connecting to Internet even though it was connected to Wi-Fi and signal strength seemed to be on max.
Answered By - Paweł Wszoła
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.