'Cordova 5.3.1 Android app can't access the internet
I am trying to get a very simple cordova application deployed on android. It is supposed to startup and then pull in a list of countries via angular $http and display them.
For some reason it can't access the internet, to simplify the test, I've added an images tag that displays an image on the net. The image is not displaying either.
I can't get a connection to jsconsole.com working either.
I've tested it on a real device and an emulator. In both cases the app can't access the net but I can browse the net on the device and emulator.
I've included the following in my config.xml
<access origin="*" />
I've also checked the generate AndroidManifest.xml file it contains the following permissions:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
What am I missing?
here is the full config file:
<?xml version="1.0" encoding="UTF-8"?>
<widget xmlns="http://www.w3.org/ns/widgets" xmlns:gap="http://phonegap.com/ns/1.0"
id="com.domain.app" version="1.0.0">
<name>app</name>
<description>
A sample Apache Cordova application that responds to the
deviceready
event.
</description>
<author href="http://www.eclipse.org/thym" email="[email protected]">
Eclipse.org -
Thym
</author>
<content src="index.html" />
<access origin="*" />
<preference name="fullscreen" value="true" />
<preference name="webviewbounce" value="true" />
<preference name="LogLevel" value="VERBOSE" />
<feature name="App">
<param name="android-package" value="org.apache.cordova.App" />
</feature>
<feature name="Compass">
<param name="android-package"
value="org.apache.cordova.deviceorientation.CompassListener" />
</feature>
<feature name="Device Orientation">
<param name="id" value="cordova-plugin-device-orientation" /></feature>
<feature name="Device">
<param name="android-package" value="org.apache.cordova.device.Device" />
<param name="id" value="cordova-plugin-device" />
</feature>
<feature name="Notification">
<param name="android-package" value="org.apache.cordova.dialogs.Notification" />
<param name="id" value="cordova-plugin-dialogs" /></feature>
<feature name="NetworkStatus">
<param name="android-package"
value="org.apache.cordova.networkinformation.NetworkManager" />
</feature>
<feature name="Network Information">
<param name="id" value="cordova-plugin-network-information" />
</feature>
<engine name="android" version="4.1.0"/>
</widget>
Here is the manifest file:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.domain.app"
android:hardwareAccelerated="true"
android:versionCode="100008"
android:versionName="1.0.0" >
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="22" />
<supports-screens
android:anyDensity="true"
android:largeScreens="true"
android:normalScreens="true"
android:resizeable="true"
android:smallScreens="true"
android:xlargeScreens="true" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<application
android:hardwareAccelerated="true"
android:icon="@drawable/icon"
android:label="@string/app_name"
android:supportsRtl="true" >
<activity
android:name="com.domain.app.MainActivity"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale"
android:label="@string/activity_name"
android:launchMode="singleTop"
android:theme="@android:style/Theme.Black.NoTitleBar"
android:windowSoftInputMode="adjustResize" >
<intent-filter android:label="@string/launcher_name" >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Solution 1:[1]
There also seems to be a separate issue where freshly created apps, or apps upgraded from older version of Cordova will have cordova-plugin-whitelist@1 installed automatically.
For some reason, this version of plugin does not work when installed in this automatic way (including the version installed by cordova create!) even with proper CSP and access tags.
Removing plugin and replacing it with cordova-plugin-whitelist@latest seems to fix the problem, up to and including to cause subsequent reinstallation of cordova-plugin-whitelist@1 to function properly.
Solution 2:[2]
Remove your entire workspace if you are using android 10>
- there is no whitelist-plugin
- there is a lot of issues with access and dependencies
Install Cordova 8.0 and android 6-8
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Annar Hiid |
| Solution 2 | Steven Foserson |
